css三角形-边框三角形(各种角度)
程序员文章站
2024-02-20 14:17:46
...
一、效果图
二、代码
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style>
.sjx-t {
width: 0;
height: 0;
border-left: 70px solid transparent;
border-right: 70px solid transparent;
border-bottom: 100px solid red;
}
.sjx-r {
width: 0;
height: 0;
border-top: 70px solid transparent;
border-bottom: 70px solid transparent;
border-left: 100px solid red;
}
.sjx-b {
width: 0;
height: 0;
border-left: 70px solid transparent;
border-right: 70px solid transparent;
border-top: 100px solid red;
}
.sjx-l {
width: 0;
height: 0;
border-top: 70px solid transparent;
border-bottom: 70px solid transparent;
border-right: 100px solid red;
}
.sjx-box {
width: 300px;
height: 100px;
border: 1px solid #ccc;
position: relative;
margin: 40px;
border-radius: 2px;
}
.sjx-box::before {
content: '';
position: absolute;
left: -10px;
top: 50%;
transform: translateY(-50%);
border-top: 6px solid transparent;
border-bottom: 6px solid transparent;
border-right: 10px solid #ccc;
}
.sjx-box::after {
content: '';
position: absolute;
left: -8px;
top: 50%;
transform: translateY(-50%);
border-top: 6px solid transparent;
border-bottom: 6px solid transparent;
border-right: 10px solid white;
/* background: linear-gradient(to bottom, #fff 0%, #09f 100%); */
}
</style>
</head>
<body>
<!-- 三角形(上右下左) -->
<div class="sjx-t"></div>
<div class="sjx-r"></div>
<div class="sjx-b"></div>
<div class="sjx-l"></div>
<!-- 带气泡(before,after画2三角形,然后定位) -->
<!--画法参看:三角形(上右下左)-->
<div class="sjx-box">111</div>
</body>
</html>
上一篇: 正则表达式匹配(递归)