摘自http://wchhlt.blog.163.com/blog/static/24401320118152272653/
一个盒子包括: margin+border+padding+content
– 上下左右边框交界处出呈现平滑的斜线. 利用这个特点, 通过设置不同的上下左右边框宽度或者颜色可以得到小三角, 小梯形等.
– 调整宽度大小可以调节三角形形状.
示例1
一般情况下, 我们设置盒子的宽高度, 及上下左右边框, 会呈现如下图
[img]http://img.ph.126.net/tpzfc7U9W90gwy2M6Jvsyw==/1566126770435035793.jpg[/img]
#test1 {
height:20px;
width:20px;
border-color:#FF9600 #3366ff #12ad2a #f0eb7a;
border-style:solid;
border-width:20px;
}
示例2
在上面基础上, 我们把宽高度都设为0时, 会呈现上述的边界斜线.,这时, 其实我们已经看到有上下左右四个三角形了..如果, 我们把4种颜色, 只保留一种颜色, 余下3种颜色设置为透明(或者设置为和背景色相同的颜色), 那不就出现一个小三角了么
示例2_1
[img]http://img.ph.126.net/pZqaWnjXD32wD7lh09B5Wg==/1350516938274670921.jpg[/img]
#test2 {
height:0;
width:0;
overflow: hidden;
font-size: 0;
line-height: 0;
border-color:transparent transparent transparent #f0eb7a;
border-style:dashed dashed dashed solid;
border-width:20px;
}
示例2_2
[img]http://img.ph.126.net/XjUV2KdQNXMUxfshXDThUg==/2495275668556909451.jpg[/img]
#test3 {
height:0;
width:0;
overflow: hidden;
font-size: 0;
line-height: 0;
border-color:transparent transparent #12ad2a transparent;
border-style:dashed dashed solid dashed;
border-width:20px;
}
示例2_3
[img]http://img.ph.126.net/tDF-YjkfkKizLFtVklkB9g==/1011058116361622674.jpg[/img]
#test4 {
height:0;
width:0;
overflow: hidden;
font-size: 0;
line-height: 0;
border-color:#FF9600 transparent transparent transparent;
border-style:solid dashed dashed dashed;
border-width:20px;
}
示例2_4
[img]http://img.ph.126.net/-RbjkgXGbtyH7_aC4vkngA==/2777876545174411320.jpg[/img]
#test5 {
height:0;
width:0;
overflow: hidden;
font-size: 0;
line-height: 0;
border-color:#FF9600 #3366ff transparent transparent;
border-style:solid solid dashed dashed;
border-width:40px 40px 0 0 ;
}
一个盒子包括: margin+border+padding+content
– 上下左右边框交界处出呈现平滑的斜线. 利用这个特点, 通过设置不同的上下左右边框宽度或者颜色可以得到小三角, 小梯形等.
– 调整宽度大小可以调节三角形形状.
示例1
一般情况下, 我们设置盒子的宽高度, 及上下左右边框, 会呈现如下图
[img]http://img.ph.126.net/tpzfc7U9W90gwy2M6Jvsyw==/1566126770435035793.jpg[/img]
#test1 {
height:20px;
width:20px;
border-color:#FF9600 #3366ff #12ad2a #f0eb7a;
border-style:solid;
border-width:20px;
}
示例2
在上面基础上, 我们把宽高度都设为0时, 会呈现上述的边界斜线.,这时, 其实我们已经看到有上下左右四个三角形了..如果, 我们把4种颜色, 只保留一种颜色, 余下3种颜色设置为透明(或者设置为和背景色相同的颜色), 那不就出现一个小三角了么
示例2_1
[img]http://img.ph.126.net/pZqaWnjXD32wD7lh09B5Wg==/1350516938274670921.jpg[/img]
#test2 {
height:0;
width:0;
overflow: hidden;
font-size: 0;
line-height: 0;
border-color:transparent transparent transparent #f0eb7a;
border-style:dashed dashed dashed solid;
border-width:20px;
}
示例2_2
[img]http://img.ph.126.net/XjUV2KdQNXMUxfshXDThUg==/2495275668556909451.jpg[/img]
#test3 {
height:0;
width:0;
overflow: hidden;
font-size: 0;
line-height: 0;
border-color:transparent transparent #12ad2a transparent;
border-style:dashed dashed solid dashed;
border-width:20px;
}
示例2_3
[img]http://img.ph.126.net/tDF-YjkfkKizLFtVklkB9g==/1011058116361622674.jpg[/img]
#test4 {
height:0;
width:0;
overflow: hidden;
font-size: 0;
line-height: 0;
border-color:#FF9600 transparent transparent transparent;
border-style:solid dashed dashed dashed;
border-width:20px;
}
示例2_4
[img]http://img.ph.126.net/-RbjkgXGbtyH7_aC4vkngA==/2777876545174411320.jpg[/img]
#test5 {
height:0;
width:0;
overflow: hidden;
font-size: 0;
line-height: 0;
border-color:#FF9600 #3366ff transparent transparent;
border-style:solid solid dashed dashed;
border-width:40px 40px 0 0 ;
}