gpt4 book ai didi

html - 定位的东西

转载 作者:太空宇宙 更新时间:2023-11-04 14:12:21 25 4
gpt4 key购买 nike

如何使 div 位置坐标相对于标题?还是我应该相对于更大的包装器定位所有内容?

当然,它可以通过多种方式完成,但我认为最好知道通常是如何完成的。

此外,不要打开另一个问题,因为这很容易回答,

为了在网站中定位和构建内容,我使用了 div。要为 block 定位标题,我应该在其中使用 div 吗?就像你在下面看到的,

<div id="LatestQuests">
<div id="LatestQuestsTitle"> Latest Quests </div>
</div>

CSS

#LatestQuests {
display: block;
position: relative;
width: 240px;
height: 190px;
top: 68px;
left: 18px;
border-top-style: outset;
border-right-style: outset;
border-bottom-style: outset;
border-left-style: outset;
border-top-color: #000;
border-right-color: #000;
border-bottom-color: #000;
border-left-color: #000;
}

#LatestQuestsTitle {
background: #C0C0C0;
}

最佳答案

要相对于另一个元素定位,您需要将要放置的元素的位置设置为绝对位置(position: absolute),将父元素的位置设置为相对位置(position: relative)。如果没有相对父级,则使用主体。将#LatestQuests 视为一个容器,其中包含有关最新任务的信息。然后它里面的任何样式都应该以相同的方式完成(所以,是的,一个 div 用于标题,可能还有一个用于实际内容,等等)。

关于html - 定位的东西,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20642259/

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