css中border属性的特殊用法(实现特殊形状)
效果图如下:
HTML代码:
<h3>Example 1</h3>
<div class="example1"></div>
<h3>Example 12</h3>
<div class="example2"></div>
<h3>Example 3</h3>
<a href="#" class="tag">JavaScript</a>
CSS代码 :
.example1{
height: 100px;
width: 180px;
border-top: 50px solid black;
border-bottom: 50px solid wheat;
border-right: 50px solid crimson;
border-left: 50px solid crimson;
}
.example2{
width: 150px;
border-bottom: 100px solid wheat;
border-right: 50px solid transparent;
border-left: 50px solid transparent;
}
.tag {
position: relative;
background: #eee;
border-radius: 3px 0 0 3px;
color:#999;
height: 26px;
line-height: 26px;
-webkit-transition: color 0.2s;
padding: 0 20px 0 23px;
text-decoration: none;
display: inline-block;
}
.tag::before{
content:'';
position: absolute;
top: 10px;
left: 10px;
width: 6px;
height: 6px;
border-radius: 3px;
background: #fff;
}
.tag::after{
content:'';
position: absolute;
right: 0px;
top: 0px;
background: #fff;
border-top:13px solid transparent;
border-bottom: 13px solid transparent;
border-left: 10px solid #eee;
}
.tag:hover{
background: crimson;
color: white;
}
.tag:hover::after{
border-left-color: crimson;
}