当我将位置固定应用于我的标题时。正文内容与标题重叠!为什么会这样?而且,我该如何解决这个问题?它发生在 Firefox 和 Chrome 中。我添加了代码,只有 css 有什么问题?
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;
}
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
display: block;
}
body {
line-height: 1;
width: 1351px;
}
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;
}
body {
color: #A2A2A2;
padding-top: 0px;
font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
position:relative;
z-index:-1;
}
a {
color: #0090D8;
text-decoration: none;
}
a:hover,
a:focus {
text-decoration: underline;
}
#container {
width: 100%;
margin: auto;
padding: 0px;
background-color:#EBEBEB;
position:fixed;
}
header {
font-family: 'Open Sans', 'Helvetica Neue', helvetica, arial, sans-serif;
font-weight: 300;
}
header:after {
content: '';
display: block;
clear: both;
}
header #logo {
float: left;
color: #0090D8;
padding-top: 17px;
font-size: 30px;
font-style: 700;
padding-left: 15px;
}
header nav {
margin-top: 3em;
float: right;
}
header nav ul {
margin: 0;
padding-bottom:0px;
float: right;
}
header nav li {
display: inline;
}
header nav li + li {
padding-left: 4px;
}
最佳答案
将您的 HTML 正文位置设置为“相对”并应用 Z-Index -1。
关于html - 位置:固定; CSS 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22004966/