我有一个通过“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 可能存在大小问题。
我是一名优秀的程序员,十分优秀!