gpt4 book ai didi

css - 链接到 div 的 ID 从 div 顶部以下开始?

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

我有一个通过“href="#divId"'链接到的 div,而不是链接到 div 的顶部,它下降了大约 100 像素。我知道它是从 div 顶部下方开始的,因为 div 的背景延伸到页面链接的上方。这是一个已知问题吗?

    #homepage_aboutstrip {
background:url('home/images/gradient-about-background.png');
background-repeat:repeat-x;
background-size: auto 100%;
position:absolute;
margin-top:200px;
width:100%;
height:1050px;
z-index:1;
}

最佳答案

我在 IE10、IE9、FF 和 Chrome 中尝试了以下代码,但没有 100px 有趣的业务...

    <!DOCTYPE html>
<html>
<head>
<style>
#homepage_aboutstrip {
background:url('home/images/gradient-about-background.png');
background-repeat:repeat-x;
background-size: auto 100%;
position:absolute;
margin-top:200px;
width:100%;
height:1050px;
z-index:1;
border:1px solid red; /*threw this in to see if the border aligned w/text, and it does*/
}
</style>
</head>


<body>
<a style="clear:both;" href="#homepage_aboutstrip">ABOUT STRIP</a>

<div style="height:500px;">
The quick brown fox jumped over the lazy dog The quick brown fox jumped over the lazy dog The quick brown fox jumped over the lazy dog The quick brown fox jumped over the lazy dog The quick brown fox jumped over the lazy dog The quick brown fox jumped over the lazy dog The quick brown fox jumped over the lazy dog The quick brown fox jumped over the lazy dog
</div>

<div id="homepage_aboutstrip">
II - The quick brown fox jumped over the lazy dog The quick brown fox jumped over the lazy dog The quick brown fox jumped over the lazy dog The quick brown fox jumped over the lazy dog The quick brown fox jumped over the lazy dog The quick brown fox jumped over the lazy dog The quick brown fox jumped over the lazy dog The quick brown fox jumped over the lazy dog
</div>
</body>
</html>

我的代码与你的唯一不同的变量是我的代码中没有 gradient-about-background.png。 CSS 中未考虑的 .png 可能存在大小问题。

关于css - 链接到 div 的 ID 从 div 顶部以下开始?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16134061/

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