作者:漂浮胖_大卍宝 | 来源:互联网 | 2023-08-14 15:24
Having a menu like this (emphasized by a red rectangle)...
有这样的菜单(用红色矩形强调)……
how can I (in pure CSS) make this responsive so that, if there is not enough width available, the menu turns into a drop-down list (or anyway something smaller).
我如何(在纯CSS中)使这个响应,以便,如果没有足够的宽度,菜单会变成一个下拉列表(或者更小的东西)。
The question is not about implementing the drop-down list itself, but how to switch from one content to the other depending on available space.
问题不是如何实现下拉列表本身,而是如何根据可用空间从一个内容切换到另一个内容。
I know this is rather simple when using @media max-width
queries, but the problem is that I do not know the actual with of the menu items at "design time" - especially because the text gets translated and/or changed, leading to different widths depending on the actual language displayed.
我知道这在使用@media max-width查询时非常简单,但问题是我不知道“设计时”菜单项的实际含义——特别是因为文本被翻译和/或更改,导致根据实际显示的语言不同的宽度。
Perhaps, there is some CSS trick that makes a whole "text" line / content disappear if it does not fit the parent container?
也许,如果不适合父容器,会有一些CSS技巧使整个“文本”行/内容消失?
2 个解决方案