我该怎么做下面的图片呢?
我希望我的所有h1都有一条额外的粗线,但我不太确定这样做的最佳做法.
HTML:
This is Our Work
CSS:
h1{ border-bottom: 1px solid #246cb4; display: inline-block; } h1:after { content: ""; display: block; border: 1px solid black; width: 50px; margin-top: 0px; position: absolute; }
Codepen:
在这种情况下,您不需要任何伪元素.
您可以linear-gradient()
使用精确控制的大小和位置的css3绘制多个背景图像:
h1 { background-image: linear-gradient(to right, #246cb4, #246cb4), linear-gradient(to right, #246cb4, #246cb4); background-repeat: no-repeat; background-size: 100% 1px, 50px 3px; background-position: bottom 2px left, bottom 1px center; }
h1{
background-image: linear-gradient(to right, #246cb4, #246cb4),
linear-gradient(to right, #246cb4, #246cb4);
background-size: 100% 1px, 50px 3px;
background-repeat: no-repeat;
background-position: bottom 2px left, bottom 1px center;
position: relative;
display: inline-block;
}
This is Our Work