Html 粘性页脚文本移动

Html 粘性页脚文本移动,html,css,Html,Css,我实现了一个粘性头 但是,当它到达粘贴点时,文本向下移动,移出容器 我想把它粘在容器里 我的HTML和Jq: <div id="container"> <div id="menu"> <ul> <li><a href='#'>Line 1</a></li> <li><a href='#'>Line 2</a></li>

我实现了一个粘性头

但是,当它到达粘贴点时,文本向下移动,移出容器

我想把它粘在容器里

我的HTML和Jq:

<div id="container">
<div id="menu">
    <ul>
        <li><a href='#'>Line 1</a></li>
        <li><a href='#'>Line 2</a></li>
        <li><a href='#'>Line 3</a></li>
    </ul>
</div>
</div>
提前谢谢


Michael

这种元素移动是因为您的元素具有defalut边距。只需添加css

ul {
    margin:0;
}
但是,您最好在样式表的开头添加css重置,例如这一个

 /**
 * Eric Meyer's Reset CSS v2.0 (http://meyerweb.com/eric/tools/css/reset/)
 * http://cssreset.com
 */
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed, 
figure, figcaption, footer, header, hgroup, 
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
    margin: 0;
    padding: 0;
    border: 0;
    font-size: 100%;
    font: inherit;
    vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure, 
footer, header, hgroup, menu, nav, section {
    display: block;
}
body {
    line-height: 1;
}
ol, ul {
    list-style: none;
}
blockquote, q {
    quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
    content: '';
    content: none;
}
table {
    border-collapse: collapse;
    border-spacing: 0;
}

您应该使用css重置,因为所有浏览器都有默认的css规则,这可能会导致您的页面在不同浏览器之间呈现不同

谢谢@antonboritskiy,另一个注意事项是,由于我实现了粘贴,下面的文本被按下。你知道为什么吗?你的意思是:“你认为水移动得很快吗?你应该看到冰。它…”?好的,你有一个上下边距为50px,上边距为30px的,看起来你不知道如何调试html标记,我建议你使用谷歌Chrome浏览器,右击html页面,然后选择“inspect element”然后您将看到所选对象以及所有应用的样式。我以前的帖子有用吗?@atonboritskiy,确实很有用。谢谢!
ul {
    margin:0;
}
 /**
 * Eric Meyer's Reset CSS v2.0 (http://meyerweb.com/eric/tools/css/reset/)
 * http://cssreset.com
 */
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed, 
figure, figcaption, footer, header, hgroup, 
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
    margin: 0;
    padding: 0;
    border: 0;
    font-size: 100%;
    font: inherit;
    vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure, 
footer, header, hgroup, menu, nav, section {
    display: block;
}
body {
    line-height: 1;
}
ol, ul {
    list-style: none;
}
blockquote, q {
    quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
    content: '';
    content: none;
}
table {
    border-collapse: collapse;
    border-spacing: 0;
}