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

时间:2013-06-19 03:04:32

标签: css pseudo-element

我很难找到一个解决方案来根据我的喜好设计一个hr元素。

如果您查看以下小提琴,您将看到hr元素同时具有:before和:之后添加了伪。

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

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

<hr class="bolt">
hr {
  border: 0 solid #eeedef;
  border-top-width: 1px;
  height: 0;
  margin-top: 60px;
  margin-bottom: 60px;
  float: left;
  clear: both;
  display: block;
  width: 100%;
  position: relative;
}
hr:before, hr:after {
  content: " ";
  width: 5px;
  height: 5px;
  position: absolute;
  -webkit-border-radius: 50%;
  -moz-border-radius: 50%;
  border-radius: 50%;
  border: 1px solid #e5e5e5;
  background-color: #fff;
}
hr:before {
  left: 0;
  bottom: -3px;
}
hr:after {
  bottom: -3px;
  right: 0;
}

非常感谢。

干杯

1 个答案:

答案 0 :(得分:4)

您可以使用:

  1. 一个伪绘制2轮,第一轮绘制边框, 第二个是影子。
  2. 带来图像的另一个伪。
  3. http://codepen.io/gcyrillus/pen/dHaus

相关问题