我有一个包含较大文本元素的 HTML 页面。我希望文本与包含的 div 的底部对齐,以便它接触到 div 的底部。
我尝试跟随,但文本和底部之间仍然有一些空格。有什么方法可以删除这个空格并使文本接触底部吗?
Here是我尝试过的活生生的例子。
<html lang="en">
<head>
<style type="text/css">
.bottomAlignedText {
position: relative;
}
.bottomAlignedText span {
position: absolute;
bottom: 0;
left: 0;
}
</style>
</head>
<body>
<div class="bottomAlignedText" style="width: 600px; height: 600px; border: 1px solid;">
<span style="font-size:300px;">Test</span>
</div>
</body>
</html>
你可以这样做line-height
.bottomAlignedText {
position: relative;
}
.bottomAlignedText span {
position: absolute;
bottom: 0;
left: 0;
line-height: 0.7;
}
<body>
<div class="bottomAlignedText" style="width: 600px; height: 600px; border: 1px solid;">
<span style="font-size:300px;">Test</span>
</div>
</body>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)