問(wèn)題描述
是否有一個(gè) CSS 規(guī)則可以根據(jù)元素的寬度匹配元素?如果沒(méi)有,在標(biāo)準(zhǔn)中提出這個(gè)建議會(huì)不會(huì)很有趣?
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;}
讓所有小代碼標(biāo)簽強(qiáng)制換行.
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.
推薦答案
是否有根據(jù)寬度匹配元素的 CSS 規(guī)則?
Is there a CSS rule that would match elements based on their width?
沒(méi)有.
如果不是,在標(biāo)準(zhǔn)中提出這個(gè)建議會(huì)很有趣嗎?
If not, would it be interesting to propose that in the standard?
也許可以,但不是 Selectors 標(biāo)準(zhǔn),因?yàn)?Selectors 并不打算與 CSS 的樣式方面緊密結(jié)合.
Maybe, but not the Selectors standard, because Selectors is not intended to be tightly coupled with the styling aspect of CSS.
幾年前曾有人提議將一種稱為元素查詢"的東西標(biāo)準(zhǔn)化,但除了一些概念驗(yàn)證之外,它們似乎大多已消散.可能是因?yàn)樗鼈儫o(wú)法以穩(wěn)健的方式規(guī)范和實(shí)現(xiàn)(循環(huán)依賴立即浮現(xiàn)在腦海).
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).
這篇關(guān)于基于寬度的CSS選擇器?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!