CSS-边框属性

       边框有3个属性:一是边框宽度属性,用于设置边框的宽度;二是边框颜色,用于设置边框的颜色;三是边框样式,用于设置边框的样式。

 1.1边框样式border-style

       使用边框样式属性可以定义边框的风格样式,这个属性必须用于指定可见的边框。可以分别设置上边框样式border-top-style、下边框样式border-bottom-style、左边框样式border-left-style和右边框样式border-right-style。

语法:

border-style:样式表

border-top-style:样式值

border-rigth-style:样式值

border-bottom-style:样式值

border-left-style:样式值

举例:

<head>
<meta http-equiv="content-type" content="text/html;charset=gb2312"/> 
    <title>边框样式</title>
    <style type ="text/css">
        <!--
       .b {
             border-top-style :dashed ;
             border-right-style :dashed ;
             border-bottom-style :dotted ;
             border-left-style :solid ;
        }
        -->
        </style>
</head>
<body>
    <img src="images/biao.jpg" width="119" height ="188" align="left">
    红色的花朵让我想到火,白色的花朵让我想到雪.
    火与雪是不相容的:但是这两盆花却融洽地开在一起,宛如火上有雪,
    或雪上有火.我故而乐之,小小的心灵里觉得十分奇妙,十分有趣
</body>
</html>


1.2边框宽度 border-width

边框宽度用于设置元素边框的宽度。

语法:

border-width:宽度值

border-top-width:宽度值

border-rigth-width:宽度

border-bottom-width:宽度

border-left-width:宽度
说明:

边框宽度border-width的取值范围如下:

medium表示默认宽度;

thin表示小于默认宽度;

thick表示大于默认宽度;

<head>
<meta http-equiv="content-type" content="text/html;charset=gb2312"/> 
    <title>边框样式</title>
    <style type ="text/css">
        <!--
       .b {
             border-top-style :dashed ;
             border-right-style :dashed ;
             border-bottom-style :dotted ;
             border-left-style :solid ;
             border-top-width:2px;
             border-top-width:2px;
             border-bottom-width:2px;
             border-left-width:2px;
        }
        -->
        </style>
</head>
<body>
    <img src="images/biao.jpg" width="119" height ="188" align="left">
    红色的花朵让我想到火,白色的花朵让我想到雪.
    火与雪是不相容的:但是这两盆花却融洽地开在一起,宛如火上有雪,
    或雪上有火.我故而乐之,小小的心灵里觉得十分奇妙,十分有趣
</body>
</html>


1.3  边框颜色 border-color
border-color 属性用来设置边框的颜色,可以用16种颜色的关键字或RGB值来设置。

语法:

border-top-color:颜色值

border-rigth-color:颜色

border-bottom-color:颜色

border-left-color:颜色

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html;charset=gb2312"/> 
    <title>边框样式</title>
    <style type ="text/css">
        <!--
       .b {
             border-top-style :dashed ;
             border-right-style :dashed ;
             border-bottom-style :dotted ;
             border-left-style :solid ;
             border-top-width :2px;
             border-top-width :2px;
             border-bottom-width :2px;
             border-left-width :2px;
             border-top-color :#ff9900;
             border-right-color :#0099ff;
             border-bottom-color :#cc33ff;
             border-left-color :#ccffff;
        }
        -->
        </style>
</head>
<body>
    <img src="images/biao.jpg" width="119" height ="188" align="left">
    红色的花朵让我想到火,白色的花朵让我想到雪.
    火与雪是不相容的:但是这两盆花却融洽地开在一起,宛如火上有雪,
    或雪上有火.我故而乐之,小小的心灵里觉得十分奇妙,十分有趣
</body>
</html>


1.4 边框属性 border
使用border属性可以设置元素的边框样式、宽度和颜色。

语法:

border:边框宽度边框样式颜色值

border-top:上边框宽度上边框样式颜色值

border-rigth:右边框宽度右边框样式颜色值

border-bottom:下边框宽度下边框样式颜色值

border-left:左边框宽度左边框样式颜色值

说明:

       边框属性border只能同时设置4个边框,也只能给出一组边框的宽度和样式,而其他的边框属性只能给出某一个边框的属性,包括样式、宽度和颜色。




评论 11
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值