CSS - 如果内容溢出到新行,应用另一种风格 [英] CSS - Apply Another Style if Content Overflows to New Line
本文介绍了CSS - 如果内容溢出到新行,应用另一种风格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个div,其中包含一个图像和文本。如果文本只占用一行,我想要文本垂直对齐到图像的中心。如果文本占用多行文本,我希望文本的顶部与图像的顶部对齐。
I have a div that contains an image and text. If the text takes up only one line, I want the text to be vertically aligned to the center of the image. If the text takes up more then one line of text, I want the top of the text to be aligned with the top of the image.
CSS有一种方法检测文本何时换行到下一行?
Does CSS have a way of detecting when text wraps to the next line?
推荐答案
不,CSS无法检测到这样的事情。这只是一种造型语言,没有做出决定的潜力。
No, CSS can't detect such things. It is only a styling language and has no potential for making decisions.
这篇关于CSS - 如果内容溢出到新行,应用另一种风格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文