基于宽度的CSS选择器?

标签 css css-selectors

是否有 CSS 规则可以根据元素的宽度匹配元素?如果没有,在标准中提出这个建议是否有趣?

可以做类似 code:max-width(200px) { white-space: nowrap; } 让所有小代码标记强制换行。

我知道我可以使用一些 js。

最佳答案

Is there a CSS rule that would match elements based on their width?

没有。

If not, would it be interesting to propose that in the standard?

也许,但不是选择器标准,因为选择器不打算与 CSS 的样式方面紧密结合。

几年前有人提议标准化称为“元素查询”的东西,但除了一些概念验证之外,它们似乎已经基本消失。可能是因为它们无法以稳健的方式进行规范和实现(循环依赖性立即浮现在脑海中)。

关于基于宽度的CSS选择器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49056690/

相关文章:

html - 为什么高度不为 : 100% and width: 100% work?

javascript - 如何使用脉动点调出模态框

css - 如何将 CSS 规则应用于其中包含特定关键字的类?

jquery - 为什么 $ ("#RadioButtons:checked").val() 在 IE 中不起作用?

javascript - 有什么方法可以使 window.scrollTo(0, 1) 流畅地动画化?

jquery - 如何实现 “select all” 复选框并在 HTML 中显示 div 中的值?

css - 无法加载图像标志+ SINTIA wordpress 主题

iPhone Safari :last-child not rendering in table

python - NoSuchElementException : Message: Unable to locate element while trying to locate an element using Selenium and Python

css - 如何创建向下滚动的菜单? CSS