0

我有一个通过 '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;
    }
4

1 回答 1

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。.png 可能存在大小问题,在 css 中未考虑到该问题。

于 2013-04-22T05:14:36.813 回答