<section class="gallerycontain"> <div class="wrapper"> <div class="box"> <img src="./img/dipesh-gurav-vWvEjapyEmA-unsplash_350x200.jpg"> </div> <div class="box"> <img src="./img/dipesh-gurav-vWvEjapyEmA-unsplash_350x200.jpg"> </div> <div class="box"> <img src="./img/dipesh-gurav-vWvEjapyEmA-unsplash_350x200.jpg"> </div> <div class="box"> <img src="./img/dipesh-gurav-vWvEjapyEmA-unsplash_350x200.jpg"> </div> <div class="box"> <img src="./img/dipesh-gurav-vWvEjapyEmA-unsplash_350x200.jpg"> </div> <div class="box"> <img src="./img/dipesh-gurav-vWvEjapyEmA-unsplash_350x200.jpg"> </div> </div> </div> </section>
.gallerycontain{ width: 100%; height:400px; border: 1px solid black; margin-top:40px ; } .gallerycontain .wrapper{ width:90%; height:400px; margin: auto; border: 1px solid red; } .box{ display: block; width:32%; height: 200px; float: left; display:block; margin-right:1% ; } .box img{ width:100%; height:95%; }
</div>
<section>
.gallerycontain .wrapper { width: 90%; height: 400px; margin: auto; border: 1px solid red; display: flex; flex-wrap: wrap; gap: 1%; } .box { flex: 1 0 32%; height: 200px; }
nth-child
.box { display: block; width: 32.66%; /* (100% - 2%) ÷ 3 */ height: 200px; float: left; display: block; margin-right: 1%; } .box:nth-child(3n){ margin-right: 0; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)