Prefer shrinking over growing in a flex container with flex-flow: row wrap

前端 未结 3 1632
失恋的感觉
失恋的感觉 2021-01-12 02:06

Displaying an image gallery of different sized images and ratio with the following specs:

  1. No blanks (margins) between images.
  2. Respecting the original
3条回答
  •  鱼传尺愫
    2021-01-12 02:20

    one way you can solve it is by adding line-height: 0 to the a and setting the height value with px value.

    section {
      display: flex;
      flex-flow: row wrap;
      justify-content: center;
    }
    section a {
      flex: auto;
      line-height: 0;
    }
    section img {
      height: 300px;
      width: 100%;
      object-fit: cover;
    }
    
    
    
        Controlling flex growability
        
        
    
    
        
    Kitty Kitty Kitty Kitty Kitty Kitty Kitty Kitty Kitty Kitty Kitty Kitty Kitty Kitty Kitty Kitty Kitty Kitty Kitty Kitty

提交回复
热议问题