CSS border style

CSS border style

You can use border-style to set the border style, or you can set the top, bottom, left, and right styles separately:

border- top-style

border-left-style

border-right-style

border -bottom-style

There are many kinds of border styles, which can be defined, such as single border, dotted border, solid border, double border, and border without border.

<html>
    <head>
        <title>测试内边距</title>
        <meta charset="utf-8">
        <!-- 调用CSS样式表 -->
        <style type="text/css">
            p.none{border-style: none;}/*设置无边的边框*/
            p.dotted {border-style: dotted}/*设置点状边框*/
            p.dashed {border-style: dashed}/*设置虚线边框*/
            p.solid {border-style: solid}/*设置实线边框*/
            p.double {border-style: double}/*设置双线边框*/    
            p.groove {border-style: groove}/*设置3D凹槽边框*/        
            p.ridge {border-style: ridge}/*设置3D垄状边框*/
            p.inset {border-style: inset}/*设置3D inset 边框*/
            p.outset {border-style: outset}/*设置3D outset 边框*/
        </style>
    </head>
    <body>
        <p class="none">我没有边框</p>
        <p class="dotted">点状边框</p>
        <p class="dashed">虚线边框</p>
        <p class="solid">实线边框</p>
        <p class="double">双线边框</p>
        <p class="groove">3D凹槽边框</p>
        <p class="ridge">3D 垄状边框</p>
        <p class="inset">3D inset 边框</p>
        <p class="outset"> 3D outset 边框</p>
    </body>
</html>

CSS border width and color

Border width

The border width is defined by border-width, which can be set up, down, left and right respectively. Properties

border-top-width

border-bottom-width

border-left-width

border-right-width

Border color

The border width is defined by border-color, and the upper and lower sides can also be set separately Left and right 4 attributes

border-top-color

border-bottom-color

border-left -color

border-right-color

<!DOCTYPE html>
<html>
    <head>
        <title>测试内边距</title>
        <meta charset="utf-8">
        <!-- 调用CSS样式表 -->
        <style type="text/css">
            /*定义p标签,是实线边框*/
            p {border-style: solid;}
            .all {
                /*定义所有边框宽度为5像素*/
                border-width: 5px; 
                /*定义所有边框是颜色为橙色*/
                border-color: #FF8000
            }
            .top {
                /*定义上边框宽度为5像素*/
                border-top-width: 5px; 
                /*定义上边框是颜色为橙色*/
                border-top-color: #FF8000
            }
            .bottom {
                /*定义下边框宽度为5像素*/
                border-bottom-width: 5px; 
                /*定义下边框是颜色为橙色*/
                border-bottom-color: #FF8000
            }
            .left {
                /*定义左边框宽度为5像素*/
                border-left-width: 5px; 
                /*定义左边框是颜色为橙色*/
                border-left-color: #FF8000
            }
            .right {
                /*定义右边框宽度为5像素*/
                border-right-width: 5px; 
                /*定义右边框是颜色为橙色*/
                border-right-color: #FF8000
            }
        </style>
    </head>
    <body>
        <p class="all">我是设置所有边框的</p>
        <p class="top">我只负责上面</p>
        <p class="bottom">我负责下面</p>
        <p class="left">我设置的是左边</p>
        <p class="right">我设置的是右边</p>
    </body>
</html>

Set each border individually

In CSS, you can specify different borders on different sides:

Example

p
{
border-top-style:dotted;
border -right-style:solid;
border-bottom-style:dotted;
border-left-style:solid;
}


above Examples can also set a single attribute:

border-style:dotted solid;


The border-style attribute can have 1- 4 values:

border-style: dotted solid double dashed;

The upper border is dotted

The right border is solid

The bottom border is double

The left border is dashed

border-style:dotted solid double;

The top border is dotted

The left and right borders are solid

The bottom border is double

border-style:dotted solid;

The top and bottom borders are dotted

The right and left borders are solid

border-style:dotted;

The four-sided borders are dotted


The border also has the abbreviation attribute

border: 5px solid red;

Continuing Learning
||
<!DOCTYPE html> <html> <head> <title>测试内边距</title> <meta charset="utf-8"> <!-- 调用CSS样式表 --> <style> .blue { border:1px dotted LightSkyBlue; } .red { border:5px solid red; } </style> </head> <body> <div> 默认无边框div </div><br/> <div class="blue"> 点状蓝色细边框 </div><br/> <div class="red"> 红色粗边框 </div><br/> </body> </html>
submitReset Code
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!