How can I display list items vertically as columns using CSS?

Susan Sarandon
Release: 2024-11-17 10:17:03
Original
209 people have browsed it

How can I display list items vertically as columns using CSS?

CSS Columns: Displaying List Items Vertically

In response to the challenge of displaying list items vertically as columns, we turn to CSS3 columns. This feature allows us to effortlessly achieve the desired layout.

Consider the following HTML code:

<div>
Copy after login

Now, we'll add CSS to style it:

#limheight {
    height: 800px; /* Fixed height */
    -webkit-column-count: 3; /* WebKit prefix */
    -moz-column-count: 3; /* Mozilla prefix */
    column-count: 3; /* Standard */
}

#limheight li {
    display: inline-block; /* Necessary for columns to work */
}
Copy after login

With CSS columns, the specified number of columns (in this case, 3) is created automatically. It dynamically adjusts the width of the columns as the browser resizes. This provides the desired vertical line-up of list items.

Enjoy the power of CSS columns to enhance your responsive layouts and elegantly display list items as columns!

The above is the detailed content of How can I display list items vertically as columns using CSS?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template