css實現帶尖括號的橫線
阿新 • • 發佈:2021-01-29
目錄
效果圖
原理
css偽元素 + 兩個三角形重疊(border)
程式碼
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</ title>
<style>
.line{
margin: 30px;
position: relative;
width: 100px;
height: 2px;
background: #1145bf;
}
.line::before,
.line::after{
content: '';
position: absolute;
left: 50%;
bottom: 0;
width: 0;
height: 0;
margin-left : -5px;
border: 5px solid;
border-color: transparent transparent #1145bf;
}
.line::after {
border-width: 3px;
margin-left: -3px;
border-color: transparent transparent #fff;
}
</style>
</head>
<body>
<div class="line"></div >
</body>
</html>