Home>Article>Web Front-end> How to implement image barrel layout in CSS3? (with code)

How to implement image barrel layout in CSS3? (with code)

青灯夜游
青灯夜游 forward
2020-07-14 09:59:18 2821browse

This article will introduce to you through code examples how to use CSS3 to implement image barrel layout. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to everyone.

How to implement image barrel layout in CSS3? (with code)

The layout with the same height but different widths is called barrel layout. It has several distinctive features: the pictures in each row are highly consistent; the pictures in each row are full.

Ideas:

1. Container flex layout
2. Set the height of the picture and exceed the line break
3. Set flex-grow: 1 for all pictures; to fill the entire row
4. Set object-fit: cover; for all pictures to solve the problem of picture deformation
5. Container: after pseudo-class sets flex-grow: 9999; and the value is high enough to solve the problem when the number of pictures in the last row is small. Still full of the whole line and too flat and long

The code is as follows, copy it and use it:

       

Rendering:

How to implement image barrel layout in CSS3? (with code)

More cool CSS3, html5, javascript special effects codes, all in:js special effects collection!

The above is the detailed content of How to implement image barrel layout in CSS3? (with code). For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:cnblogs.com. If there is any infringement, please contact admin@php.cn delete