Why auto-fit or auto-fill not working properly with minmax?

后端 未结 4 632
臣服心动
臣服心动 2021-02-10 16:17

It doesn\'t work properly when I add auto-fit or auto-fill instead of a number.

 grid-template-columns: repeat(auto-fit, minmax(max-content, max-content));
         


        
4条回答
  •  忘掉有多难
    2021-02-10 17:00

    Add some width (in this example I added 'width: 100vw;' to 'ul' tag) to a tag you want a 'repeat' to apply.

    * {
      margin: 0;
      padding: 0;
      box-sizing: border-box;
    }
    
    ul {
     width: 100vw;
     display: grid;
     grid-template-columns: repeat(auto-fit, minmax(50px, 1fr));
     grid-gap: 10px;
    }
    
    li {
      list-style: none;
    }
    
        
      

    Add some width to a tag you want a 'repeat', 'min-max' to apply.

提交回复
热议问题