I want to create a div container, that contains 6 images. Here is an image:
Inside this container should be more then 6 images, so I used the :nth-child()
selector in css. My problem is, that the 6th image is pushed in the next row, and I dont know why.
Here is the code:
*{
margin: 0px;
padding: 0px;
}
div{
width: 750px;
background-color: grey;
}
div > a{
display: inline-block;
height: 120px;
width: 120px;
max-height: 120px;
max-width: 120px;
margin-right: 6px;
}
div > a:nth-child(6n){
margin-right: 6px;
}
div > a > img{
height: 120px;
width: 120px;
max-height: 120px;
max-width: 120px;
}
<div>
<a>
<img src="http://lorempixel.com/120/120/"/>
</a>
<a>
<img src="http://lorempixel.com/120/120/"/>
</a>
<a>
<img src="http://lorempixel.com/120/120/"/>
</a>
<a>
<img src="http://lorempixel.com/120/120/"/>
</a>
<a>
<img src="http://lorempixel.com/120/120/"/>
</a>
<a>
<img src="http://lorempixel.com/120/120/"/>
</a>
</div>
Here is a JSFiddle