I'm trying to place an image before and after div
using :before
and :after
.
Unfortunately, I don't see images. Why?
Here is the code (and in jsfiddle):
<div style="border:1px solid green; padding:50px;">
<div id="videos-part">test</div>
</div>
#videos-part{
height: 127px;
width: 764px;
border:1px solid red;
margin:30px;
padding:30px;
}
#videos-part:before{
width: 46px;
height:46px;
content: "before ";
background-image: url(http://aux.iconpedia.net/uploads/136059938344542682.png);
}
#videos-part:after{
width: 46px;
height:46px;
content: " after";
background-image: url(http://aux.iconpedia.net/uploads/136059938344542682.png);
}
Using
pseudo element
you can add images and custom icon and create custom shapes as well. Check the DEMO first.here's an updated fiddle http://jsfiddle.net/vlrprbttst/u234x/7/
1) the urls of your images are wrong (i've put a placeholder) 2)
content
must stay empty 3) you may need to applyrelative
to the parentdiv
andabsolute
to the pseudo elements:before
and:after
and place them usingtop
/bottom
left
/right
valuesAdd
display:inline-block
to#videos-part
before and after selectors.Updated fiddle here.
You need to apply this syntax:
content: url(imageURL);
with nobackground-image
.CSS:
Demo