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.

demo

edit:

i'm sorry don't unsderstand question @ beggining. use simple css:

#artiststhumbnail img {     position: relative;     left: 50%;     transform: translatex(-50%); } 

demo2


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -