CSS选择器基于宽度? [英] CSS selector based on width?

查看:100
本文介绍了CSS选择器基于宽度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有CSS规则可以根据元素的宽度进行匹配?如果不是,那么在标准中提出该建议会很有趣吗?

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?

可以执行code:max-width(200px) { white-space: nowrap; }之类的功能,以使所有小的代码标签强制换行.

One could do something like code:max-width(200px) { white-space: nowrap; } to have all small code tag force line break.

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

I know I could use some js.

推荐答案

是否有CSS规则可以根据元素的宽度进行匹配?

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?

也许是,但不是Selectors标准,因为Selectors并非旨在与CSS的样式方面紧密结合.

Maybe, but not the Selectors standard, because Selectors is not intended to be tightly coupled with the styling aspect of CSS.

几年前,有人提出了一些标准化元素查询"的建议,但是除了一些概念验证之外,它们似乎已经消失了.可能是因为它们只是以健壮的方式规范和实施(马上就会想到循环依赖),所以不可行.

There were proposals to standardize something called "element queries" a few years ago, but other than a few proofs-of-concept, they seem to have mostly dissipated. Probably because they're just not feasible to spec and implement in a way that is robust (cyclic dependencies immediately come to mind).

这篇关于CSS选择器基于宽度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆