简体   繁体   English

自适应-一排图片,有些带有边框

[英]Responsive - row of images, some having borders

I am trying to figure out how best to make the 2 rows of 4 images each on this page work responsively. 我正在尝试找出如何最好地使此页面上的2行(每行4张图像)以响应方式工作。

http://www.ashtonbrewingcompany.com/index-real.html http://www.ashtonbrewingcompany.com/index-real.html

Right now I have set each DIV within the row to width: 24%. 现在,我将行中的每个DIV设置为width:24%。 This would work fine if it weren't for the fact I need to have the borders appear on every other image. 如果不是因为我需要使边框出现在其他所有图像上,这将很好用。

Right now the image to the right of a bordered image ends up overlapping the border when the viewport gets smaller. 现在,当视口变小时,带边框图像右侧的图像最终会与边框重叠。

 <div class="instagram-container"> <div class="insta-content"> <div class="row01 inrow"> <div><span><img src="_img/insta-01.png" /></span></div> <div><span class="frame-01"><img src="_img/insta-02.png" /></span></div> <div><span><img src="_img/insta-03.png" /></span></div> <div><span class="frame-02"><img src="_img/insta-04.png" /></span></div> </div> <div style="clear:both;"></div> <div class="row02 inrow"> <div class="frame-03"><img src="_img/insta-05.png" /></div> <div><img src="_img/insta-06.png" /></div> <div class="frame-04"><img src="_img/insta-07.png" /></div> <div><img src="_img/insta-08.png" /></div> </div> <div style="clear:both;"></div> </div> </div> </div> 

 .instagram-container { padding: 120px 20px 60px 20px; width: 99%; margin: 0 auto; } .insta-content { text-align: center; } .row01 div { display: inline-block; width: 24%; } .row01 div span { display: inline-block; } 

They are overlapping because you are using display:inline-block . 它们重叠,因为您正在使用display:inline-block If you use display:block; 如果使用display:block; and float: left then the overlap will go away (although you may have to adjust some of your other spacing). 然后float: left ,重叠部分就会消失(尽管您可能需要调整一些其他间距)。 Typically then you would remove the float at a mobile breakpoint so each div is full width. 通常情况下,您将在移动断点处删除float ,以便每个div为全宽。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM