gpt4 book ai didi

html - 无法使标题位于页面顶部

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

我正在尝试为我的页面制作标题,但它不会转到页面顶部。我试过 CSS 重置,但没有用,我也试过将高度单位移动到 %、px 和 vh,但这也没有用。

CSS:

<style>
#heading {
position: fixed;
top: 0vh;
left: 0px;
width: 100%;
text-align: center;
background-color: rgba(140,120,83,0.96);
color: rgba(8,37,150, 0.8);
</style>

HTML:

<h1 id="heading"> Anything </h1> 

最佳答案

<h1>通过<h5>标记具有内置边距

您需要从 h1 中删除边距标签:

#heading {
position: fixed;
top: 0vh;
left: 0px;
width: 100%;
text-align: center;
background-color: rgba(140,120,83,0.96);
color: rgba(8,37,150, 0.8);
margin:0; /* added this */
}

此外,确保您的 CSS 正确关闭。您问题中的 CSS 未关闭。

关于html - 无法使标题位于页面顶部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36393358/

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