從Vals的僅CSS示例開始,此示例使用相同的基本CSS代碼,但它適用於li
的僞元素,這意味着不需要額外的div。
CodePen:http://cdpn.io/wlKHj
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<style>
ul{
list-style-type: none;
width: 200px;
margin: 0;
padding: 0;
}
ul li{
background-color: red;
padding: 20px 30px 20px 10px;
color: #000000;
position: relative;
border-top: 1px solid #000000;
}
li:after {
content: "";
position: absolute;
z-index: 10;
width: 30px;
bottom: 0px;
top: 0px;
right: -30px;
background-image: linear-gradient(to top right, red 50%, transparent 51%), linear-gradient(to bottom right, red 50%, transparent 51%);
background-size: 100% 50% ;
background-position: top left, bottom left;
background-repeat: no-repeat;
}
</style>
</head>
<body>
<ul>
<li>
test 1
</li>
<li>
test 1
</li>
<li>
test 2
</li>
<li>
test 3
</li>
<li>
test 4 test 4 test 4 test 4 test 4 test 4
</li>
</ul>
</body>
</html>
你所需要的是[這](https://www.google.co.in/search?q=css+responsive+triangle&ie=utf-8&oe=utf- 8&rls = org.mozilla:en-US:official&client = firefox -a&gws_rd = cr&ei = 6E_rUqe4H4uMrgfUl4DIDA) –