问题
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 :before and :after pseudos added to it.
http://jsfiddle.net/MattStrange/LGEjp/
So far this is what i want, both circles on either side is correct but now i want to add an image to the exact center of the line, but because both pseudos are taken up i'm not sure how to add a background image to this hr.
<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;
}
Help very much appreciated.
Cheers
回答1:
You can use :
- one pseudo to draw the 2 rounds, first round is drawn with borders, the second is its shadow.
- another pseudo to bring in the image.
http://codepen.io/gcyrillus/pen/dHaus
来源:https://stackoverflow.com/questions/17182245/achieving-this-hr-element-with-css-styling-pseudo-elements