CSS: Display li elements side by side
Question by Guest | 2018-04-21 at 09:37
I would like to format the li elements of a ul list with CSS so that they appear next to each other instead of under each other.
Sense of the thing is that I want to make my website responsive and the list should, as soon as the page becomes smaller, no longer be displayed at the side but next to each other over the content.
Related Topics
CSS: Include CSS Stylesheets in HTML
Tutorial | 0 Comments
Website Performance: Deliver JavaScript and CSS files compressed to reduce loading times
Tutorial | 0 Comments
jQuery: CSS Stylesheet Switcher
Tutorial | 1 Comment
Darken Background of a Website (Gray Out Effect)
Tutorial | 0 Comments
Reload Images, CSS, JS and Web Pages despite Browser Cache
Tip | 2 Comments
HTML: Difference between ID and CLASS
Info | 0 Comments
jQuery: Count Elements, Images, Classes etc
Tip | 0 Comments
Important Note
Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.
Participate
Ask your own question or write your own article on askingbox.com. That’s how it’s done.
The li elements are block elements by default and are therefore displayed one below the other. With display: inline or display: inline-block you can change this property and display the elements inline next to each other:
At this point it makes sense to change also some other formatting:
With this, we make sure that in addition to the display next to each other, the bullets in front of the list entries disappear and there is a little distance between the items.
You said you only want to apply the li-change when the page width in the browser decreases. You can do that as shown in the last example. With that CSS, the list formatting becomes active only with a window width smaller than 600px.
2018-04-21 at 21:09