Displaying List Items in Columns using CSS3
Problem Statement:
Building a responsive layout requires displaying list items vertically, with the number of columns determined by the browser's width.
CSS3 Solution:
CSS3 columns provide an efficient solution for this layout:
#limheight { height: 300px; /* Define the container's height */ -webkit-column-count: 3; -moz-column-count: 3; column-count: 3; /* Specify the desired number of columns */ } #limheight li { display: inline-block; /* Ensure each list item is treated as a block element */ }
Example:
<ul>
When the browser window is wide enough, the list items will be displayed in three columns:
1 4 7 2 5 8 3 6 9
As the browser window narrows, the columns will dynamically adjust to maintain a visually appealing layout.
The above is the detailed content of How to create a responsive list layout with dynamically adjusting columns using CSS3?. For more information, please follow other related articles on the PHP Chinese website!