2016-08-05 36 views
1

上定位任何竞争,当我尝试将h3添加到网站上时,它只停留在顶部我尝试在CSS中使用位置,顶部,左侧但它不我不想回应它。我也试图用w3schools的一个画廊模板来看看它是否会让我移动画廊,但仍然没有运气。我试图研究这个,但我没有运气。很抱歉,长码。页脚和标题不会允许我在网站

<html> 
<link rel="stylesheet" href="sheet.css"> 
<head> 
<title> Jon Barton </title> 
</head> 
<header> 
<ul class= "nav-men"> 
<li><a HREF="Gallery.html"> Gallery</a> </li>  
<li><a HREF= "JB.html">About me</a> </li> 
<li><a HREF= "contractme.html"> Contract me</a></li> 
</ul> 
<h1><span> Software Developer </span> </h1> 
<p class = "kicker" >Ideas // Desinger // Implement </p> 
</header> 
<body> 
<h3> Work</h3> 
<footer> 
<div class = "footer"> 
<div class ="content-wrap"> 
<ul> 
<li><a href= "Gallery.html "> </a></li> 
<li><a href = "JB.html"> </a></li> 
<li><a href= "contractme.html"> </a></li> 
</ul> 
<p class = "copyright"> All content copyright 2016</p> 
</div> 
</div> 
</html> 

css有点遗憾,有些只是重复。

#css 
    header { 

background: url(.//277H.jpg) ; 
text-align: center; 
width: 100%; 
height: auto; 
position: absolute; 
    } 

.nav-men li { 
display:inline; 
margin-left: 100px ; 

} 


.nav-men ul{ 


margin: 30px 30px 0px 0px; 
padding: 0; 
list-style-type: none; 
text-align: center; 
text-decoration: none; 

} 



    .nav-men a { 
      color:white; 
} 



    .nav-men a:hover, a:visited, a:link, a:active 
    { 
text-decoration: none; 
} 


h1 { 
font-size: 60px; 
color: white; 
letter-spacing: 0.05em; 
text-transform: uppercase; 
text-align: center; 
font-weight: 700; 
margin-bottom: 20px; 
} 

span { 
    display: inline-block; 
padding: 0.2em 0.6em ; 
border: white solid 10px; 
} 


.kicker { 
    text-align: center; 
    font-weight: 700; 
    text-transform: uppercase; 
    letter-spacing: 0.5em; 
    color: white; 
    } 




    body { 
    margin: 0; 
    padding: 0; 
    height: 100%; 
    } 


    .alt-selction { 
     background: black; 
     } 

    .thumb-container { 
max-width: 980px ; 
margin: 0px auto ; 
padding-bottom: 100px; 
     } 

.thumb-unit { 
    display:block; 
    width: 25%; 
    height: 150px; 
    float:left ; 
    } 



    .footer { 
    margin: 30px; 
    background: url(../277H.jpg) ; 
    width: 100%; 
    height: 100px; 
    clear: both; 
    bottom: -53px; 
    left:-30; 
    right:0; 
    position: absolute; 
    background-size: cover; 
    float: left; 
    } 

    .content-wrap { 
    float: left; 
    } 


li {  
display:inline; 
margin-left: 100px ; 
} 


ul{ 

margin: 30px 30px 0px 0px; 
padding: 0; 
list-style-type: none; 
text-align: center; 
text-decoration: none; 

} 

a { 

    color:white; 


} 


    a:hover, a:visited, a:link, a:active { 
text-decoration: none; 
} 

回答

2

这是因为<header>footer的位置是绝对的。 position:absolute定位在元素相对于最近定位的祖先,而不是相对于定位在视口,等固定。(从here

从类header & .footer卸下position:absolute。然后它会让你把任何东西放在它们之间。

0

我建议先清理一下你的HTML,把你的页眉和页脚放在body元素内,然后正确关闭你的body元素,否则你很可能会遇到其他问题。

看到这个捣鼓一个例子: https://jsfiddle.net/jowxoaca/1/

而且,jonju提到,去除position:absolute页眉和页脚会解决您的订购问题。