Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
73
rated 0 times [  77] [ 4]  / answers: 1 / hits: 18254  / 9 Years ago, thu, june 25, 2015, 12:00:00

I'm looking for how to add a play icon to Image on CSS.



I tried this code, but it doesn't appear right I want it to appear on the center :



    .video { position: relative; }

.video a {
position: absolute;
display: block;
background: url(http://www.slatecube.com/images/play-btn.png);
height: 100%;
width: 100%;
top: 20px;
left: 20px;
}


html :



<div class=video >  
<img style=height:200pxsrc=http://san.capitalafrique.com/imatin.net/articles/images/lionel-messi.jpg />
<a href=#></a>
</div>


here is the jsFiddle :



DEMO


More From » html

 Answers
114

DEMO



you should set background-size



.video a {
position: absolute;
display: block;
background: url(http://www.slatecube.com/images/play-btn.png);
height: 100%;
width: 100%;
top: 75px;
left: 150px;
background-size: 50px 50px;
background-repeat: no-repeat;
}

[#66057] Tuesday, June 23, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
josefn

Total Points: 251
Total Questions: 93
Total Answers: 84

Location: Senegal
Member since Fri, Aug 21, 2020
4 Years ago
;