通过给一个盒子添加渐变背景的方式来实现画一条中间粗两头细的线条的效果
效果如图:
代码如下:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CSS实现中间粗两头细的线条</title>
<style>
.line{
width: 500px;
height: 1px;
background: -webkit-linear-gradient(left, #fff -4%,#ff0000 50%,#fff 100%);
}
</style>
</head>
<body>
<div class="line"></div>
</body>
</html>