我有以下 html/css 代码,我试图使 b 大于其他两个字母:
<!DOCTYPE html>
<html>
<head>
<title></title>
<style type="text/css">
p {
display: inline;
}
</style>
</head>
<body>
<p style="font-size: 20px">a</p>
<p style="font-size: 30px">b</p>
<p style="font-size: 20px">c</p>
</body>
</html>
但是,我希望所有字母“从顶部开始”,b“向下增加其大小”,如附图所示,而不是所有字母“从底部开始”和 b“增加其大小”尺寸向上”,如代码中所示。有人知道该怎么做吗?
最佳答案
如果为 body 元素或第二个 p 元素指定 vertical-align: top; 样式,使其与顶部对齐并向下延伸而不是垂直对齐,那么您应该会获得所需的效果底部对齐并向上延伸。
<!DOCTYPE html>
<html>
<head>
<title></title>
<style type="text/css">
p {
display: inline;
}
</style>
</head>
<body>
<p style="font-size: 20px">a</p>
<p style="font-size: 30px;vertical-align: top;">b</p>
<p style="font-size: 20px">c</p>
</body>
</html>
关于html - 如何使字体大小增加向下而不是向上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71372937/