简体   繁体   English

如何在回显四个项目后创建一个新列?

[英]How to make a new column after four items are echoed?

So, I'm making a shop for my virtual, online game and I want there to be four items for every row. 所以,我正在为我的虚拟在线游戏开店,我希望每一行都有四个项目。 The items are fetched from the database. 这些项目是从数据库中提取的。 I'm using bulma for the css framework. 我正在使用bulma作为css框架。 I basically want the rows to be a little like this: http://bloxtopia.xyz/Shop/ <- (Where the items are) 我基本上希望行有点像这样: http//bloxtopia.xyz/Shop/ < - (项目所在的位置)

Here's what it would look like on the front end side 这是前端的外观

  <div class="column"> item 1 </div><div class="column"> item 2 </div><div class="column"> item 3 </div><div class="column"> item 4 </div></div> <div class='columns'><div class="column"> item 5 on new line because of (<div class='columns'><div class="column">) </div> 
So basically, after every four items are echoed, <div class='columns'> is added 所以基本上,每回动四个项目后,就会添加<div class='columns'>

You can use this, it will automatically return you 4-columns in a row. 你可以使用它,它会自动连续返回4列。

 * { box-sizing: border-box; } /* Create four equal columns that floats next to each other */ .column { float: left; width: 25%; padding: 10px; height: 300px; /* Should be removed. Only for demonstration */ margin-bottom: 5px; } /* Clear floats after the columns */ .row:after { content: ""; display: table; clear: both; } 
 <h2>Four Equal Columns</h2> <div class="row"> <div class="column" style="background-color:#aaa;"> <h2>Column 1</h2> <p>Some text..</p> </div> <div class="column" style="background-color:#bbb;"> <h2>Column 2</h2> <p>Some text..</p> </div> <div class="column" style="background-color:#ccc;"> <h2>Column 3</h2> <p>Some text..</p> </div> <div class="column" style="background-color:#ddd;"> <h2>Column 4</h2> <p>Some text..</p> </div> <div class="column" style="background-color:#aaa;"> <h2>Column 1</h2> <p>Some text..</p> </div> <div class="column" style="background-color:#bbb;"> <h2>Column 2</h2> <p>Some text..</p> </div> <div class="column" style="background-color:#ccc;"> <h2>Column 3</h2> <p>Some text..</p> </div> <div class="column" style="background-color:#ddd;"> <h2>Column 4</h2> <p>Some text..</p> </div> <div class="column" style="background-color:#aaa;"> <h2>Column 1</h2> <p>Some text..</p> </div> <div class="column" style="background-color:#bbb;"> <h2>Column 2</h2> <p>Some text..</p> </div> <div class="column" style="background-color:#ccc;"> <h2>Column 3</h2> <p>Some text..</p> </div> <div class="column" style="background-color:#ddd;"> <h2>Column 4</h2> <p>Some text..</p> </div> </div> 

Is there a specific need to create a new group of columns? 是否有特定需要创建新的列组? Bulma allows multiline column containers. Bulma允许多行列容器。 https://bulma.io/documentation/columns/options/ https://bulma.io/documentation/columns/options/

As @Christhofer Natalius mentioned, use .is-one-quarter on the columns, but don't forget the .is-multiline on the main .columns container! 正如@Christhofer Natalius所提到的,在列上使用.is .is-one-quarter ,但不要忘记main .columns容器上的.columns .is-multiline

This method allows you to not care how many items are returned, they will wrap accordingly without needing to make a new column wrapper for every 4 items. 此方法允许您不关心返回多少项,它们将相应地换行,而不需要为每4个项目创建一个新的列包装器。

 <link href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.7.4/css/bulma.min.css" rel="stylesheet"/> <div class="columns is-multiline is-mobile"> <div class="column is-one-quarter">item 1</div> <div class="column is-one-quarter">item 2</div> <div class="column is-one-quarter">item 3</div> <div class="column is-one-quarter">item 4</div> <div class="column is-one-quarter">item 5</div> <div class="column is-one-quarter">item 6</div> <div class="column is-one-quarter">item 7</div> <div class="column is-one-quarter">item 8</div> </div> 

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

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