I am trying to arrange 6 iframes in two rows such that each row contains three iframes. What I want to do is, have margin with each iframe but the margin with the iframes that touch it's container should be zero. Here is the code:
* {
box-sizing: border-box;
}
.bodycontainer3 {
width: 100%;
display: flex;
flex-wrap: wrap;
justify-content: center;
padding: 10px 0;
padding-bottom: 0;
border: 2px dotted red;
}
.bodycontainer3 iframe {
width: 32%;
margin: 1%;
}
.bodycontainer3 iframe:nth-of-type(1),
.bodycontainer3 iframe:nth-of-type(4) {
margin-left: 0;
}
.bodycontainer3 iframe:nth-of-type(3),
.bodycontainer3 iframe:nth-of-type(6) {
margin-right: 0;
}
<body>
<div class="bodycontainer3">
<iframe src="https://www.youtube.com/embed/Q5911Zy7Jos?autoplay=0" autoplay="0" allowfullscreen="allowfullscreen"></iframe>
<iframe src="https://www.youtube.com/embed/r2rmtwOFLx0?autoplay=0" autoplay="0" allowfullscreen="allowfullscreen"></iframe>
<iframe src="https://www.youtube.com/embed/AA_TxwrizzQ?autoplay=0" autoplay="0" allowfullscreen="allowfullscreen"></iframe>
<iframe src="https://www.youtube.com/embed/OaRCWjp4WFo?autoplay=0" autoplay="0" allowfullscreen="allowfullscreen"></iframe>
<iframe src="https://www.youtube.com/embed/lwbs1BQr0qI?autoplay=0" autoplay="0" allowfullscreen="allowfullscreen"></iframe>
<iframe src="https://www.youtube.com/embed/q3gOHGbppIc?autoplay=0" autoplay="0" allowfullscreen="allowfullscreen"></iframe>
</div>
</body>
Now each iframe has width 32% so three iframes take 32%*3 = 96%
. The margin due to collapsing is 1%*2 = 2%
. So the total width of a row must be 96% + 2% = 98%
.
My question is where is the remaining 2%
space? Are margins not collapsing?