In typesetting
use the nowrap attribute on tags that wrap plain text to instantly force no line breaks Line break.
For example:
Force no line break
Force no line break
In hypertext using div
Force elements such as div, h1, section, nav, a, li to become inline elements
display:inline;
Then you can operate it like the first case.
Make the sub-tag ul itself have the width of wrap-content (borrowing the key adjective of android layout)
nav>ul>li*10>a[href='#']{random link$}
nav{ fixed width width:40em; nowrap attribute white-space:nowrap; }
ul,li,a{ inline element display:inline; eliminate floating float:none; }
// It is necessary for li to become inline
When ul is not inline, the maximum width of ul itself is the width of the parent nav;
When ul is inline, the width of ul is the wrap-content width.
See my navigation for demo