Achieving this hr element with CSS styling - pseudo elements

后端 未结 1 1482
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-11 12:22

I\'m having some difficulty finding a solution to style a hr element to my preference.

If you look at the following fiddle you will see the hr element has both :befo

相关标签:
1条回答
  • 2020-12-11 13:05

    You can use :

    1. one pseudo to draw the 2 rounds, first round is drawn with borders, the second is its shadow.
    2. another pseudo to bring in the image.

    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}
    <hr/>

    0 讨论(0)
提交回复
热议问题