Home >Web Front-end >CSS Tutorial >How to Create a Responsive Separator for Horizontal Lists That Disappears on Line Breaks?

How to Create a Responsive Separator for Horizontal Lists That Disappears on Line Breaks?

Patricia Arquette
Patricia ArquetteOriginal
2024-12-17 14:55:10500browse

How to Create a Responsive Separator for Horizontal Lists That Disappears on Line Breaks?

Responsive Separator for Horizontal List

Question:

How can you remove separators at line breaks caused by changes in viewport size?

Example:

| Item 1 | Item 2 | Item 3 | Item 4 | Item 5 |
|---|---|---|---|---|

When the viewport narrows:

Item 1 Item 2 Item 3
Item 4 Item 5

Note that the separator remains at the line break.

Possible Solution:

CSS-only:

You can leverage the collapsing of trailing white spaces:

b {
    background: red;
    outline: 1px solid blue;
}
div {
    resize: both;
    overflow: hidden;
}
<div>
    word<b> </b>.repeat(42)
</div>

The above is the detailed content of How to Create a Responsive Separator for Horizontal Lists That Disappears on Line Breaks?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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