.square { float:left; position: relative; width: 100px; padding-bottom : 100px; /* = width for a 1:1 aspect ratio */ margin:1.66%; background-position:center center; background-repeat:no-repeat; background-size:cover; /* you change this to "contain" if you don't want the images to be cropped */ } .img_1{background-image:url('2016/stall/1.jpg');} .img_2{background-image:url('2016/stall/2.jpg');} .img_3{background-image:url('2016/stall/3.jpg');} .img_4{background-image:url('2016/stall/4.jpg');} .img_5{background-image:url('2016/stall/5.jpg');} .img_6{background-image:url('2016/stall/6.jpg');} .img_7{background-image:url('2016/stall/7.jpg');} .img_8{background-image:url('2016/stall/8.jpg');} .img_9{background-image:url('2016/stall/9.jpg');} .img_10{background-image:url('2016/stall/10.jpg');} .img_11{background-image:url('2016/stall/11.jpg');} .img_12{background-image:url('2016/stall/12.jpg');} .img_13{background-image:url('2016/stall/13.jpg');} .img_14{background-image:url('2016/stall/14.jpg');} .img_15{background-image:url('2016/stall/15.jpg');} .img_16{background-image:url('2016/stall/16.jpg');} .img_17{background-image:url('2016/stall/17.jpg');}