理解盒子的border

<!doctype = html>
<html>
<head>
<meta charset="UTF-8"/>
<title>Css3中的border</title>
<style type = "text/css">
body{margin:100px;}
div{
margin:30px;
}

.div1{
border-top:20px solid red ;
border-right:20px solid blue ;
border-bottom:20px solid yellow ;
border-left:20px solid black ;
width:30px;
height:30px;
<!-- 每个边单独画是一个等腰梯形 -->
}
.div2{

border-style:solid dashed dashed dashed;
border-width:40px;
border-color:#F00 transparent transparent transparent;
width:0px;
height:0px;
}
.div3{
margin-top:20px;
border-top:40px solid red ;
border-right:40px solid blue ;
border-bottom:40px solid yellow ;
border-left:40px solid black ;
width:60px;
height:40px;
border-radius:10px; 

<!-- border-radius:10px用来设置盒子的圆角; -->
}

.div4{
margin-top:20px;
border-top:40px solid red ;
border-right:40px solid blue ;
border-bottom:40px solid yellow ;
border-left:40px solid black ;
width:60px;
height:40px;
border-radius:10px; 

<!-- border-radius:10px用来设置盒子的圆角,可以有两个参数,
第一个表示横向半径,第二个表示纵向半径,只写一个默认两个参数相同; 
当参数为50%时,表示两边都为圆角
-->
}

.div5{
margin-top:20px;
border-top:1px solid red ;
border-right:1px solid blue ;
border-bottom:1px solid yellow ;
border-left:1px solid black ;
width:60px;
height:40px;
border-radius:20px; 
background-color:#CCC;


<!-- border-radius:10px用来设置盒子的圆角,共有左上/右上/右下/左下四个参数,一个参数可以有两个值,
第一个表示横向半径,第二个表示纵向半径,只写一个默认两个参数相同; 
单位可以是像素也可以是百分数;
-->

}

.div6{
margin-top:20px;
border-top:1px solid red ;
border-right:1px solid blue ;
border-bottom:1px solid yellow ;
border-left:1px solid black ;
width:160px;
height:100px;
border-radius:50%/50%; 
background-color:#CCC;
<!-- 当参数为50%时,表示盒子为椭圆;

-->
}
</style>
</head>
<body>
<div class="div1">DIV1</div>
<div class="div2">DIV2</div>
<div class="div3">DIV3</div>
<div class="div4">DIV4</div>
<div class="div5">DIV5</div>
<div class="div6">DIV6</div>
</body>

</html>


最终效果


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值