I've been struggling to figure this out. Initially, when I attempted to keep the text below the image, it was constantly floated to the left. While this code seems to be effective, I suspect I made an error because when the width of .resmontage ul
is changed from 70%
to 60%
, all the images shrink. They no longer adhere to the width
or height
I initially specified.
Why is it necessary to set .resmontage img
to width: 100%
to align it with .resmontage li
? If the width is removed from resmontage li
, everything falls apart! While bootstrap is an option, I prefer to handle this myself.
#bt {
color: white;
margin-top: 1%;
margin-left: -8%;
}
.resmontage ul {
float: left;
background-color: black;
width: 70%;
height: 25%;
padding-left: 7%;
margin-top: 1%;
border-radius: 1%;
}
.resmontage li {
list-style-type: none;
width: 20%;
margin-top: 1%;
float: left;
padding-right: 3%;
}
.resmontage img {
width: 100%;
height: 65%;
}
.hello {
text-align: center;
color: white;
margin-top: 2%;
}
.clearfix:after {
content: "";
display: both;
clear: both;
}
<div class="resmontage clearfix">
<ul>
<div id="bt">Games that will be released next month.</div>
<li>
<img src="https://upload.wikimedia.org/wikipedia/en/a/a5/Grand_Theft_Auto_V.png" />
<div class="hello">Gta v</div>
</li>
<li>
<img src="http://media.steampowered.com/apps/valvestore/images/slider/store_image_02.png" />
<div class="hello">CSGO</div>
</li>
<li>
<img src="https://upload.wikimedia.org/wikipedia/commons/e/e0/Rocket_League_coverart.jpg" />
<div class="hello">Rocket League</div>
</li>
<li>
<img src="http://blogs-images.forbes.com/erikkain/files/2014/12/The-Witcher-3-Wild-Hunt.jpg" />
<div class="hello">Witcher 3</div>
</li>
</ul>
</div>