Example code for implementing card waterfall layout with css3 column

Example code for implementing card waterfall layout with css3 column

This article introduces the sample code of CSS3 column to realize the card waterfall layout, which is shared with you as follows:

Achieve results

Today I encountered the problem of implementing a waterfall layout of cards, and the heights of the cards were different.

Finally, I used the column attribute in CSS3 to implement this layout, and it was very simple (I vaguely remember that the last time I wrote the waterfall flow, I used JS to implement it... naive)

The effect is as follows:

Related properties

  1. column-count: the number of columns you want to achieve, I only need 2 columns here
  2. column-width: The width of the column
  3. column-gap: The gap between columns
  4. break-inside:avoid: If you do not set this attribute for the child elements (each card), a card will be truncated and displayed in different columns.

Problems encountered

  1. I encountered a small problem during the implementation process. The bottom border of my card would be cut off.
  2. Solved by setting overflow:auto on child elements

Code

       .videoCards {
            padding-top: 4rpx;
            column-count: 2;
            column-gap: 18rpx;

            .card {
                display: inline-block;
                margin-top: 20rpx;
                width: 326rpx;
                background: #FFFFFF;
                box-shadow: 0 0 10rpx 0 rgba(0,0,0,0.10);
                border-radius: 14rpx;
                break-inside: avoid;
                padding-bottom: 20rpx;
                overflow:auto;
                }
        }

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

<<:  How to use domestic image warehouse for Docker

>>:  Learn Hyperlink A Tag

Recommend

Detailed explanation of Linux file permissions and group modification commands

In Linux, everything is a file (directories are a...

Use of Linux xargs command

1. Function: xargs can convert the data separated...

This article takes you to explore NULL in MySQL

Table of contents Preface NULL in MySQL 2 NULL oc...

(MariaDB) Comprehensive explanation of MySQL data types and storage mechanisms

1.1 Data Type Overview The data type is a field c...

Implementation of Nginx load balancing/SSL configuration

What is load balancing? When a domain name points...

Solution to Django's inability to access static resources with uwsgi+nginx proxy

When deploying uwsgi+nginx proxy Django, access u...

js to realize simple shopping cart function

This article example shares the specific code of ...

The difference between br and br/ in HTML

answer from stackflow: Simply <br> is suffic...

Sample code for implementing history in vuex

I have recently been developing a visual operatio...

Example of JSON output in HTML format (test interface)

To display the JSON data in a beautiful indented ...

CentOS7.x uninstall and install MySQL5.7 operation process and encoding format modification method

1. Uninstalling MySQL 5.7 1.1查看yum是否安裝過mysql cd y...

25 Tools to Improve Website Usability and Conversion Rates

For a website, usability refers to whether users c...

How to upgrade all Python libraries in Ubuntu 18.04 at once

What is pip pip is a Python package management to...