Answer the question
In order to leave comments, you need to log in
How to align an image in a block to the center?
Hello. There is a 160*160 block containing a 160*250 widescreen image.
<div id="minibox">
<img src="img/1.jpg" class="box">
</div>
.box {
height:100%;
}
#minibox {
overflow:hidden;
width:160px;
height:160px;
}
Answer the question
In order to leave comments, you need to log in
Make an image the background, the easiest solution.
I would still suggest that you correct the engine template. If you insist on using img, then on the server or on the client, change the margin-left of each image. Here is an example for a js client (+jq)
codepen.io/iiil/pen/EGFns
#minibox {
overflow:hidden;
width:160px;
background: url(../img/1.jpg);
height:160px;
background-size: cover;
background-position:center;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question