2017-09-13 37 views
1

所以我一直在這個問題上停留了一個多星期,這讓我瘋狂。我想把我的頁腳放在我的網頁底部。出於某種原因,它只是想浮在頁面中間,就在我最後一個div的下面。我做了大量的研究並嘗試了一百萬種不同的東西,而且他們都沒有給我我需要的結果。爲什麼我的頁腳不能移動到頁面的底部?

這裏有幾個解決辦法的,我試過:

  • 我與position屬性發揮各地,將其設置爲「絕對」「相對」「固定''Relative'將頁腳向下推,同時也將其下面的內容向下推。 '絕對'工作在它的最底部,但由於某種原因它削減了頁腳的寬度。 (我嘗試手動調整寬度,但沒有運氣)。與'固定'同樣的事情。

  • 我設置頁邊距和 HTML內容的填充0。

  • 予設定的主體的高度爲100%。

  • 我檢查確認所有標籤都已關閉。

  • 我試過把腳註放在身體的外面。

  • 我試過在頁腳之前和附近創建新的div。

在這一點上,我不確定問題是什麼。有人能幫助我嗎?

body { 
 
    background-color: white; 
 
    background-image: url(http://michellewalling.com/wp-content/uploads/2015/10/purple-planet.jpg); 
 
    background-size: cover; 
 
    max-height: 100%; 
 
} 
 

 
ul { 
 
    list-style-type: none; 
 
    font-family: "Lucida Console"; 
 
    
 
} 
 

 
li { 
 
    font-size: 150%; 
 
    font-family: Abel; 
 
    display: inline; 
 
    width: 390px; 
 
    margin: 18px; 
 
    position: relative; 
 
    bottom: -21px; 
 
} 
 

 

 
div.well { 
 
    background-color: black; 
 
    height: 55px; 
 
    width: 1609px; 
 
    position: relative; 
 
    left: -17px; 
 
    top: -20px; \t 
 
} 
 

 
.container { 
 
\t min-height: 100%; \t 
 
} 
 

 
div.main { 
 
    background-image: url(); 
 
    text-align: center; 
 
    position: relative; 
 
    padding-top: 20px; 
 
    position: relative; 
 
    bottom: -40px; 
 
    min-height: 100%; 
 
} 
 

 
p { 
 
    color: white; 
 
    text-align: center; 
 
    position: relative; 
 
    bottom: -50px; 
 
    padding-bottom: 200px; 
 
} 
 

 
h1 { 
 
    text-align: center; 
 
    font-family: "Londrina Shadow"; 
 
    font-size: 600%; 
 
    color: black; 
 
    letter-spacing: 0.2em; 
 
} 
 

 
h2 { 
 
    font-family: Chewy; 
 
    font-size: 300%; 
 
    color: black; 
 
    padding-bottom: 20px; 
 
    position: relative; 
 
    top: -60px; 
 
} 
 

 
li a:hover { 
 
\t background-color: gainsboro; 
 
\t color: black; 
 
} 
 

 

 
.links { 
 
    text-align: center; 
 
    letter-spacing: 15px; 
 
} 
 

 
.youtube { 
 
    position: relative; 
 
    bottom: -3px; 
 
} 
 

 
.dailymotion { 
 
    position: relative; 
 
    top: -1px; 
 
} 
 

 

 
/* html, body { 
 
\t height: 100%; 
 
\t padding: 0; 
 
\t margin: 0; \t 
 
} */ 
 

 

 
.footer { 
 
\t background-color: black; 
 
\t height: 100px; 
 
\t padding: 0; 
 
\t margin: 0; \t 
 
}
<!DOCTYPE html> 
 
<html> 
 
    <head> 
 
    <title>iHeartFandomz.net</title> 
 
    </head> 
 
<body> 
 

 
<!-- Google fonts --> 
 
<link href="https://fonts.googleapis.com/css?family=Londrina Shadow" type="text/css" rel="stylesheet"> 
 
<link href="https://fonts.googleapis.com/css?family=Kavivanar" type="text/css" rel="stylesheet"> 
 
<link href="https://fonts.googleapis.com/css?family=Baloo Bhaijaan" type="text/css" rel="stylesheet"> 
 
<link href="https://fonts.googleapis.com/css?family=Acme" type="text/css" rel="stylesheet"> 
 
<link href="https://fonts.googleapis.com/css?family=Chewy" type="text/css" rel="stylesheet"> 
 
<link href="https://fonts.googleapis.com/css?family=Luckiest Guy" type="text/css" rel="stylesheet"> 
 
<link href="https://fonts.googleapis.com/css?family=Abel" type="text/css" rel="stylesheet"> 
 
<link href="https://fonts.googleapis.com/css?family=Raleway" type="text/css" rel="stylesheet"> 
 

 
<link rel = "stylesheet" type = "text/css" href = "iheartfandomz.css"/> 
 

 
<div class="container"> 
 
<div class="col-xs-6"> 
 
    <div class="well"> 
 
    <ul> 
 
    <li class="active"><a href="#Home" data-toggle="tab" style="text-decoration:none">Home</a></li> 
 
    <li><a href="#Videos" data-toggle="tab" style="text-decoration:none">Videos</a></li> 
 
    <li><a href="#Fanart" data-toggle="tab" style="text-decoration:none">Fanart</a></li> 
 
    </ul> 
 
    </div> 
 
    </div> 
 

 
<div class="main"> 
 
\t \t <h1>iHeartFandomz</h1> 
 
\t \t <h2>Fandoms Collection</h2> 
 
\t </div> 
 

 
<div class="links"> 
 
    <a href="https://www.youtube.com/user/HeartzHugzKissez" target="_blank"><img class="youtube" src="https://cdn1.iconfinder.com/data/icons/logotypes/32/youtube-512.png" style="width: 55px;"></a> 
 
    <a href="https://twitter.com/i_Heart_fandomz" target="_blank"><img class="twitter" src="http://icons.iconarchive.com/icons/paomedia/small-n-flat/1024/social-twitter-icon.png" style="width: 50px;"></a> 
 
    <a href="https://gabbykun555.deviantart.com/" target="_blank"><img class="deviantart" src="https://static.wixstatic.com/media/816933_9cc6964ab1b6426d818e3ea9859995f3~mv2.png" style="width: 50px;"></a> 
 
    <a href="https://www.dailymotion.com/iHeartFandomz" target="_blank"><img class="dailymotion" src="https://www.drupal.org/files/project-images/dailymotion.png" style="width: 45px;"></a> 
 
</div> 
 
</div> 
 

 
<footer class="footer"> 
 
\t <p>Here's the footer</p> 
 
</footer> 
 

 
</body> 
 
</html>

+2

除了這裏的一對CSS技巧一些更多的信息:[置頂頁腳,五種方式(https://開頭的CSS -tricks.com/couple-takes-sticky-footer/)。 – insertusernamehere

回答

2

試試這個。這會將頁腳粘在頁面的底部。我還刪除了頁腳內部的填充。

.footer { 
    position: absolute; 
    left: 0; 
    right: 0; 
    bottom: 0; 
} 
.footer p { 
    padding-bottom: 0; 
} 
+0

謝謝,這有助於推動頁腳向下。但看起來頁腳和頁面底部之間仍有間距。有沒有辦法解決這個問題? – Gabbykun555

+0

你是否應用了刪除** p **底部填充的代碼? –

+0

我做過了,但將位置從「絕對」改爲「固定」似乎解決了問題。謝謝! – Gabbykun555

1

在你的CSS變化

p { 
    color: white; 
    text-align: center; 
    position: relative; 
    bottom: -50px; 
    padding-bottom: 200px; 
} 

p { 
    color: white; 
    text-align: center; 
    position: relative; 
    bottom: -50px; 
    padding-bottom: 0px; 
} 

或者你可以嘗試

.footer p { 
    padding-bottom: 0px !important; 
} 
1

您的頁腳內有p元素,其中包含padding-bottom: 200px;

您需要將其刪除或更改footer內部的p的樣式。

0

工作小提琴:https://jsfiddle.net/zrbzf22v/

更改HTML這樣的:

<footer class="footer"> 
     <p style=" bottom: 0px; 
     padding-bottom: 0px; ">Here's the footer</p> 
    </footer> 
0
.footer { 
    background-color: black; 
    height: 100px; 
    padding: 0; 
    margin: 0; 
    position: absolute; 
    width: 100%; 
    bottom: 0; 
} 
p { 
    padding-bottom: 0px; 
} 
+0

謝謝,這個解決方案完美運作。但看起來我無法改變頁腳的高度。因爲當我嘗試時,它會在頁腳和頁面底部之間創建更多空間。除非有解決辦法嗎? – Gabbykun555

0

我用這一點,我對你的項目進行了測試。其工作

footer{ 
     position: fixed; 
     bottom: 0px; 
     width: 100%; 
     left: 0px; 
     text-align: center; 
    } 
0

檢查這個頁腳在底部

body { 
 
    background-color: white; 
 
    background-image: url(http://michellewalling.com/wp-content/uploads/2015/10/purple-planet.jpg); 
 
    background-size: cover; 
 
    max-height: 100%; 
 
    margin:0px; 
 
    width:100%; 
 
} 
 

 
ul { 
 
    list-style-type: none; 
 
    font-family: "Lucida Console"; 
 
    
 
} 
 

 
li { 
 
    font-size: 150%; 
 
    font-family: Abel; 
 
    display: inline; 
 
    width: 390px; 
 
    margin: 18px; 
 
    position: relative; 
 
    bottom: -21px; 
 
} 
 

 

 
div.well { 
 
    background-color: black; 
 
    height: 55px; 
 
    width: 1609px; 
 
    position: relative; 
 
    left: -17px; 
 
    top: -20px; \t 
 
} 
 

 
.container { 
 
\t min-height: 100%; \t 
 
} 
 

 
div.main { 
 
    background-image: url(); 
 
    text-align: center; 
 
    position: relative; 
 
    padding-top: 20px; 
 
    position: relative; 
 
    bottom: -40px; 
 
    min-height: 100%; 
 
} 
 

 
p { 
 
    color: white; 
 
    text-align: center; 
 
    position: relative; 
 
    bottom: -50px; 
 
    padding-bottom: 0px; 
 
} 
 

 
h1 { 
 
    text-align: center; 
 
    font-family: "Londrina Shadow"; 
 
    font-size: 600%; 
 
    color: black; 
 
    letter-spacing: 0.2em; 
 
} 
 

 
h2 { 
 
    font-family: Chewy; 
 
    font-size: 300%; 
 
    color: black; 
 
    padding-bottom: 20px; 
 
    position: relative; 
 
    top: -60px; 
 
} 
 

 
li a:hover { 
 
\t background-color: gainsboro; 
 
\t color: black; 
 
} 
 

 

 
.links { 
 
    text-align: center; 
 
    letter-spacing: 15px; 
 
} 
 

 
.youtube { 
 
    position: relative; 
 
    bottom: -3px; 
 
} 
 

 
.dailymotion { 
 
    position: relative; 
 
    top: -1px; 
 
} 
 

 

 
/* html, body { 
 
\t height: 100%; 
 
\t padding: 0; 
 
\t margin: 0; \t 
 
} */ 
 

 

 
.footer { 
 
\t background-color: black; 
 
\t height: 100px; 
 
\t padding: 0; 
 
\t margin: 0; \t 
 
}
<!DOCTYPE html> 
 
<html> 
 
    <head> 
 
    <title>iHeartFandomz.net</title> 
 
    </head> 
 
<body> 
 

 
<!-- Google fonts --> 
 
<link href="https://fonts.googleapis.com/css?family=Londrina Shadow" type="text/css" rel="stylesheet"> 
 
<link href="https://fonts.googleapis.com/css?family=Kavivanar" type="text/css" rel="stylesheet"> 
 
<link href="https://fonts.googleapis.com/css?family=Baloo Bhaijaan" type="text/css" rel="stylesheet"> 
 
<link href="https://fonts.googleapis.com/css?family=Acme" type="text/css" rel="stylesheet"> 
 
<link href="https://fonts.googleapis.com/css?family=Chewy" type="text/css" rel="stylesheet"> 
 
<link href="https://fonts.googleapis.com/css?family=Luckiest Guy" type="text/css" rel="stylesheet"> 
 
<link href="https://fonts.googleapis.com/css?family=Abel" type="text/css" rel="stylesheet"> 
 
<link href="https://fonts.googleapis.com/css?family=Raleway" type="text/css" rel="stylesheet"> 
 

 
<link rel = "stylesheet" type = "text/css" href = "iheartfandomz.css"/> 
 

 
<div class="container"> 
 
<div class="col-xs-6"> 
 
    <div class="well"> 
 
    <ul> 
 
    <li class="active"><a href="#Home" data-toggle="tab" style="text-decoration:none">Home</a></li> 
 
    <li><a href="#Videos" data-toggle="tab" style="text-decoration:none">Videos</a></li> 
 
    <li><a href="#Fanart" data-toggle="tab" style="text-decoration:none">Fanart</a></li> 
 
    </ul> 
 
    </div> 
 
    </div> 
 

 
<div class="main"> 
 
\t \t <h1>iHeartFandomz</h1> 
 
\t \t <h2>Fandoms Collection</h2> 
 
\t </div> 
 

 
<div class="links"> 
 
    <a href="https://www.youtube.com/user/HeartzHugzKissez" target="_blank"><img class="youtube" src="https://cdn1.iconfinder.com/data/icons/logotypes/32/youtube-512.png" style="width: 55px;"></a> 
 
    <a href="https://twitter.com/i_Heart_fandomz" target="_blank"><img class="twitter" src="http://icons.iconarchive.com/icons/paomedia/small-n-flat/1024/social-twitter-icon.png" style="width: 50px;"></a> 
 
    <a href="https://gabbykun555.deviantart.com/" target="_blank"><img class="deviantart" src="https://static.wixstatic.com/media/816933_9cc6964ab1b6426d818e3ea9859995f3~mv2.png" style="width: 50px;"></a> 
 
    <a href="https://www.dailymotion.com/iHeartFandomz" target="_blank"><img class="dailymotion" src="https://www.drupal.org/files/project-images/dailymotion.png" style="width: 45px;"></a> 
 
</div> 
 
</div> 
 

 
<footer class="footer"> 
 
\t <p>Here's the footer</p> 
 
</footer> 
 

 
</body> 
 
</html>