Equal width columns in CSS Grid

后端 未结 7 1241
别跟我提以往
别跟我提以往 2020-12-25 10:27

I\'d like to have the html below showing in n equal columns whether there are two, or three, or more child elements to the row element using css grid - Flexbox makes this ea

7条回答
  •  梦毁少年i
    2020-12-25 10:57

    Here is simple answer(at least in my perspective). I got this issue above answers not helped me. Here the code to divide 'div' into equal width and with required number of columns.

    //CSS
    
    .grid-container {
      display: grid;
      grid-template-columns: auto auto auto; // no of 'auto's will be number of columns here it's 3
    }
    
    //HTML
    

    more info on grid can be seen here W3Schools

提交回复
热议问题