gpt4 book ai didi

css - 如何在 CSS3 和 HTML5 中布局 2 x 3 div(包含图像和文本)的网格

转载 作者:行者123 更新时间:2023-11-28 12:40:36 24 4
gpt4 key购买 nike

我在文章内容框中有 6 个 div。

包含的 6 个 div 将每行拆分为 2 个 div

我希望这些 div 能够紧密地适应水平空间

这意味着第一个 div 应该从最左边开始,第二个应该紧靠在最右边。

布置这样的网格布局的最佳方式是什么

enter image description here

最佳答案

尝试以下操作:

<article class="container" style="overflow:hidden">
<div style="width:50%; float:left;">1st Div</div> <!-- alternate floating if your width is less than 50%. if it's 50% you can leave all float left -->
<div style="width:50%; float:right;">2nd Div</div>
<div style="width:50%; float:left;">3rd Div</div>
<div style="width:50%; float:right;">4th Div</div>
<div style="width:50%; float:left;">5th Div</div>
<div style="width:50%; float:right;">6th Div</div>
</article>

关于css - 如何在 CSS3 和 HTML5 中布局 2 x 3 div(包含图像和文本)的网格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17679676/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com