html - Change a div`s background image when hover over the image -
i have following code:
<!doctype html> <html > <head> <style type="text/css"> .imgbox {background: url(lock75.png) no-repeat; } .imgbox:hover {background: url(lock75light.png) no-repeat; } </style> </head> <body> <div style="width:200px; height:200px; border:1px solid;" class="imgbox"> </div> </body> </html>
my images 75x75 , problem occurs when hover on border image changes, want when hovering on image change image.
note: need html construction similar one.
edit
i forgot mention need picture centralized above other divs have not space picture.
thanks
you need have container can hold both background image , content in following structure (i know asked similar have posted, it's not possible; involve css3 elements , jquery)
here's setup
body { padding:10px; } .img-box { max-width:200px; width:100%; border:1px solid #ddd; } .img-box .img { width:200px; height:200px; background: url(https://unsplash.it/200/200/?image=876) no-repeat; border-bottom:1px solid #ddd; } .img-box .img:hover { background: url(https://unsplash.it/200/200/?image=876&blur) no-repeat; } p { margin:5px }
<div class="img-box"> <div class="img" ></div> <p>other content here</p> </div>
Comments
Post a Comment