1. 程式人生 > 其它 >css實現帶尖括號的橫線

css實現帶尖括號的橫線

技術標籤:csscss3

目錄

效果圖

在這裡插入圖片描述

原理

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>

參考連結