gpt4 book ai didi

html - 在内联跨度元素上指定高度的原因

转载 作者:太空宇宙 更新时间:2023-11-03 23:56:05 24 4
gpt4 key购买 nike

我只是想知道,当这是一个内联元素时,在 span 元素上指定高度真的有什么意义吗?无论我为跨度选择器的高度设置什么值,外观都不会改变。

这是完整的标记和CSS

<!DOCTYPE html>
<html>
<head>
<meta charset = "utf-8">
<title>Relative Positioning</title>
<style type = "text/css">
p
{
font-size: 1.3em;
font-family: verdana, arial, sans-serif;
}
span
{
color: red;
font-size: .6em;
height: .6em;
}
.super
{
position: relative;
top: -1ex;
}
.sub
{
position: relative;
bottom: -1ex;
}
.shiftleft
{
position: relative;
left: -1ex;
}
.shiftright
{
position: relative;
right: -1ex;
}
</style>
</head>
<body>
<p>The text at the end of this sentence
<span class = "super">is in superscript</span>.
</p>

<p>The text at the end of this sentence
<span class = "sub">is in subscript</span>.
</p>

<p>The text at the end of this sentence
<span class = "shiftleft">is shifted left</span>.
</p>

<p>The text at the end of this sentence
<span class = "shiftright">is shifted right</span>.
</p>
</body>
</html>

//托尼

最佳答案

只要<span> -元素被定义为 inline -element ( its default ) 高度值不会有影响。

来自 w3.org 规范 10.5 Content height: the 'height' property :

This property does not apply to non-replaced inline elements. See the section on computing heights and margins for non-replaced inline elements for the rules used instead.

关于html - 在内联跨度元素上指定高度的原因,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18624181/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com