html - Cannot center img horizontally -
i'm trying center image horizontally in sample http://jsfiddle.net/3k3cc/1545/ , i'm unsuccessfull. works when container wider image, need image centered if container thinner image itself.
sample css:
#artiststhumbnail { width:100px; height:308px; overflow:hidden; border-color:#dadada; border-style:solid; border-width:thin; background-color:pink; } #artiststhumbnail:hover {left:50px } #genre { font-size:12px; font-weight:bold; color:#2a2a2a } #artiststhumbnail img { display : block; margin : auto; }
sample html:
<div id="artiststhumbnail"> <a href="#"> <!--image here--> <img src="http://goo.gl/qrkcc" height="100%" alt="artist" border="1" /> </a> </div>
you should add text-align: center;
#thumbnailwrapper
, set display: inline-block;
#artiststhumbnail
.
edit:
i'm sorry don't unsderstand question @ beggining. use simple css:
#artiststhumbnail img { position: relative; left: 50%; transform: translatex(-50%); }
Comments
Post a Comment