html - Centering the center of a image in a div -


i've display html images in application width can vary important part of image on center width of approximately 120 px.

trying display image width (or percentage of it) produces other things of application not display , if set width image can become extremely deformed.

so best thing create div of fixed width , no scrollbar show center of image, if image example 400 px should show width pixel 140 width pixel 260 if 600 240 360 , on (borders wouldn't show).

i see no way knowledge this, hope can guide me, thanks.

if know image size can this

.image {     position: relative;     width: 200px; /* outer box width */     height: 200px;  /* outer box height */     overflow: hidden; } .image img {     position: absolute;     left: 50%;     margin-left: -150px; /* 50% of image width */ } 

Comments

Popular posts from this blog

IF statement in MySQL trigger -

c++ - What does MSC in "// appease MSC" comments mean? -

javascript - Blogger related post gadget image Resize s72-c [ Need Expert Help ] -