使用 CSS 样式实现此 hr 元素 - 伪元素

Sho*_*box 2 css pseudo-element

我很难找到根据我的喜好设置 hr 元素样式的解决方案。

如果您查看以下小提琴,您将看到 hr 元素同时添加了 :before 和 :after 伪代码。

http://jsfiddle.net/MattStrange/LGEjp/

到目前为止,这就是我想要的,两边的两个圆圈都是正确的,但现在我想将图像添加到线的确切中心,但是因为两个伪都被占用,我不知道如何将背景图像添加到这个小时。

<hr class="bolt">
Run Code Online (Sandbox Code Playgroud)
<hr class="bolt">
Run Code Online (Sandbox Code Playgroud)

非常感谢帮助。

干杯

G-C*_*Cyr 5

您可以使用 :

  1. 一个伪绘制2轮,第一轮是用边框绘制的,第二个是它的阴影。
  2. 另一个伪引入图像。

http://codepen.io/gcyrillus/pen/dHaus

hr {
  border: 0 solid #eeedef;
  border-top-width: 1px;
  height: 0;
  margin: 60px auto;
  clear: both;
  display: block;
  width: 400px;
  position: relative;
}
hr:before {
  content: " ";
  width: 5px;
  height: 5px;
  position: absolute;
  border-radius: 5px;
  border: 1px solid #aaa;
  background-color: #999;
}
hr:before {
  left: 0;
  bottom: -3px;
box-shadow: 400px 0 0 -1px #999, 400px 0 0 0 #aaa;
}
hr:after {
  content:url(http://lorempixel.com/50/50/cats/2);
  display:block;
  position:absolute;
  left:50%;
  height:50px;
  width:50px;
  margin:-25px 0 0 -25px;
  border-radius:50px;
  overflow:hidden;
  box-shadow: 0 0 0 1px #eef, 0 0 5px;
}
 
body {background:#789}
Run Code Online (Sandbox Code Playgroud)
<hr/>
Run Code Online (Sandbox Code Playgroud)