简体   繁体   English

用表格顺序布局元素的正确方法是什么?

[英]What is the right way to layout elements in a table order?

在此处输入图片说明


Hi i want to position my elements like in this picture. 嗨,我想像这样在图片中放置我的元素。

I tried to use flexbox but the second row required more effort to place the elements differently 我尝试使用flexbox,但是第二行需要更多的努力才能以不同的方式放置元素

I am not sure if I should use flexbox/grid or normal table for this kind of layout 我不确定是否应该使用flexbox / grid或普通表进行这种布局

Is using the table tag is not preferable? 使用table标记不是可取的吗? I would really like to see a code suggestion for this layout.. Thanks ahead 我真的很想看到这种布局的代码建议。

If I understand you correct you need simple grid. 如果我了解您的要求,那么您需要简单的网格。

 .container{ display: grid; grid-template-columns: repeat(4, 50px); grid-template-rows: repeat(4, 50px); grid-gap: 50px; } .grid-item { background-color: blue; } 
 <div class="container"> <div class="grid-item"> 1 </div> <div class="grid-item"> 2 </div> <div class="grid-item"> 3 </div> <div class="grid-item"> 4 </div> <div class="grid-item"> 5 </div> <div class="grid-item"> 6 </div> <div class="grid-item"> 7 </div> <div class="grid-item"> 8 </div> <div class="grid-item"> 9 </div> <div class="grid-item"> 10 </div> <div class="grid-item"> 11 </div> <div class="grid-item"> 12 </div> </div> 

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

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