Sure, here's how to create a grid with 6 items per row using CSS Grid:

<div class='grid-container'>
  <div>1</div>
  <div>2</div>
  <div>3</div>
  <div>4</div>
  <div>5</div>
  <div>6</div>
  <div>7</div>
  <div>8</div>
  <div>9</div>
  <div>10</div>
  <div>11</div>
  <div>12</div>
  <div>13</div>
  <div>14</div>
  <div>15</div>
  <div>16</div>
  <div>17</div>
  <div>18</div>
  <div>19</div>
  <div>20</div>
  <div>21</div>
  <div>22</div>
  <div>23</div>
  <div>24</div>
  <div>25</div>
  <div>26</div>
  <div>27</div>
  <div>28</div>
  <div>29</div>
  <div>30</div>
  <div>31</div>
  <div>32</div>
  <div>33</div>
  <div>34</div>
  <div>35</div>
  <div>36</div>
</div>
.grid-container {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
}

Explanation:

  • display: grid;: Sets the container as a grid.
  • grid-template-columns: repeat(6, 1fr);: Creates 6 columns of equal width using the repeat() function.
  • gap: 10px;: Adds a 10px gap between grid items.

This code will create a grid with 6 items per row, resulting in the following layout:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36

You can adjust the number of columns and the gap size to customize your grid.

CSS Grid: Create 6 Items Per Row Layout

原文地址: https://www.cveoy.top/t/topic/deQU 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录