CSS3 border

CSS3 Borders


With CSS3, you can create rounded borders, add shadow boxes

In this chapter, you You will learn about the following border properties

##box-shadowAppend the shadow of one or more drop-down boxes3
PropertiesDescriptionCSS
border- imageSets the shorthand properties of all border images. 3
border-radiusA shorthand property for setting all four border-*-radius properties 3

##CSS3 Rounded CornersAdding rounded corners in CSS2 is tricky. We had to use different images in every corner.

In CSS3, it is easy to create rounded corners.

The border-radius property is used to create rounded corners in CSS3:

Example

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>php中文网(php.cn)</title>
    <style>
        div
        {
            border:2px solid #4269e1;
            padding:10px 40px;
            background: #d8dd2e;
            width:150px;
            border-radius:25px;
        }
    </style>
</head>
<body>
<div>圆角边框!</div>
</body>
</html>

Run Try the program


CSS3 box shadowThe box-shadow property in CSS3 is used to add a shadow:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>php中文网(php.cn)</title>
    <style>
        div
        {
            width:300px;
            height:100px;
            background-color:yellow;
            box-shadow: 10px 10px 5px #47d1b1;
            text-align: center;
            
        }
    </style>
</head>
<body>
<div>CSS3盒阴影</div>
</body>
</html>

Run the program to try it


CSS3 border imageWith the CSS3 border-image property, you can use images Create a border: The

border-image property allows you to specify an image as a border!

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>PHP中文网(php.cn)</title>
    <style>
        div
        {
            border:15px solid transparent;
            width:250px;
            padding:10px 20px;
        }
        #round
        {
            -webkit-border-image:url(/upload/course/000/000/006/58a4feb498981164.png) 30 30 round; /* Safari 5 and older */
            -o-border-image:url(/upload/course/000/000/006/58a4feb498981164.png) 30 30 round; /* Opera */
            border-image:url(/upload/course/000/000/006/58a4feb498981164.png) 30 30 round;
        }
        #stretch
        {
            -webkit-border-image:url(/upload/course/000/000/006/58a4feb498981164.png) 30 30 stretch; /* Safari 5 and older */
            -o-border-image:url(/upload/course/000/000/006/58a4feb498981164.png) 30 30 stretch; /* Opera */
            border-image:url(/upload/course/000/000/006/58a4feb498981164.png) 30 30 stretch;
        }
    </style>
</head>
<body>
<p> border-image 属性用于设置图片的边框。</p>
<div id="round">这里,图像平铺(重复)来填充该区域。</div>
<br>
<div id="stretch">这里,图像被拉伸以填充该区域。</div>
<p>这是我们使用的图片素材:</p>
<img src="http://www.runoob.com/images/border.png" />
</body>
</html>

Run the program and try it


Continuing Learning
||
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>PHP中文网(php.cn)</title> <style> div { border:15px solid transparent; width:250px; padding:10px 20px; } #round { -webkit-border-image:url(https://img.php.cn/upload/course/000/000/006/58a4feb498981164.png) 30 30 round; /* Safari 5 and older */ -o-border-image:url(https://img.php.cn/upload/course/000/000/006/58a4feb498981164.png) 30 30 round; /* Opera */ border-image:url(https://img.php.cn/upload/course/000/000/006/58a4feb498981164.png) 30 30 round; } #stretch { -webkit-border-image:url(https://img.php.cn/upload/course/000/000/006/58a4feb498981164.png) 30 30 stretch; /* Safari 5 and older */ -o-border-image:url(https://img.php.cn/upload/course/000/000/006/58a4feb498981164.png) 30 30 stretch; /* Opera */ border-image:url(https://img.php.cn/upload/course/000/000/006/58a4feb498981164.png) 30 30 stretch; } </style> </head> <body> <p> border-image 属性用于设置图片的边框。</p> <div id="round">这里,图像平铺(重复)来填充该区域。</div> <br> <div id="stretch">这里,图像被拉伸以填充该区域。</div> <p>这是我们使用的图片素材:</p> <img src="https://img.php.cn/upload/course/000/000/006/58a4feb498981164.png" /> </body> </html>
submitReset Code