[英]How to top align two words with different font sizes the same line?
I need to display two lines of text with different font size, one after another, so that their top lines were at the same vertical position, ie: 我需要显示两行具有不同字体大小的文本,一个接一个,以便它们的顶行位于相同的垂直位置,即:
I tried to use vertical-align: top
, but no luck. 我尝试使用
vertical-align: top
,但是没有运气。 Instead of expected result I have this: 我没有得到预期的结果:
Is there some standard way to achieve the desired result? 是否有一些标准方法可以达到预期效果?
Here is my HTML: 这是我的HTML:
<div id="container">
<span>TEXT</span> TEXT
</div>
and CSS: 和CSS:
#container {
font-size: 30px;
}
#container span {
font-size: 16px;
vertical-align: top;
}
One way would be: 一种方法是:
#container span {
position: relative;
top: 2px;
}
Adjust the 2px to suit. 调整2px以适合。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.