This is my HTML and CSS:
.main {
float: left;
justify-content: center;
}
.img_list {
width: auto;
margin-left: auto;
margin-right: auto;
display: inline-block;
}
.img_item {
padding-top: 10px;
display: inline-block;
}
<div class="main">
<div class="img_list">
<div class="img_item">
<p><Hinh 1></p>
<img src="../a/1.jpg" />
</div>
<div class="img_item">
<p><Hinh 2></p>
<img src="../a/1.jpg" />
</div>
<div class="img_item">
<p><Hinh 3></p>
<img src="../a/1.jpg" />
</div>
<div class="img_item">
<p><Hinh 4></p>
<img src="../a/1.jpg" />
</div>
</div>
</div>
This is target result:
How can to center "img_list" as below:
Note: i had edit css of "main":
.main{
display: flex;
justify-content: center;
}
3
Answers
simply replace this it should work for you
The reason that content moves to left on small screen is because the screen width gets small and therefore the last image gets pushed to the next line.
I have updated my answer.
Hope this helps.