2017-01-23 51 views
1

我正在嘗試修復頁腳底部的位置。 以下是CSS頁腳沒有固定在自定義類的位置

.footer { 
    position: fixed; 
    bottom: 0; 
    width: 100%; 
    height: 25px; 
} 

的代碼,但它不工作,但是當我使用的ID爲這些屬性它的工作原理。

#footer { 
    position: fixed; 
    bottom: 0; 
    width: 100%; 
    height: 25px; 
} 

問題是爲什麼我無法使用類來修復頁腳底部的位置。這些屬性有一些規則嗎?請指教。

這裏是上述CSS

<div class="footerBar" style=""> 
    <label class="control-label" style="color: white">Copyright 2007-2017 </label> 
    <label class="control-label" style="float: right;margin-right: 10px;font-weight: bold;color: white">{{version}}</label> 

</div> 

的HTML代碼,我使用div在另一個DIV如下

<div id="footer"><!-- calling of class for footer doesn't work for me here --> 
    <footer-outlet></footer-outlet> 
</div> 
+0

你能否給我提供鏈接? –

+0

根據你的html你應該使用'.footerBar'而不是'.footer' –

+0

也許有一些其他的CSS規則重載類規則?您是否嘗試瞭解某些​​瀏覽器開發控制檯如何評估屬性? – Massimo

回答

1

嘗試用片段都工作正常

.footer { 
 
\t position:fixed; 
 
\t bottom:0; 
 
\t width:100%; 
 
\t height:100px; 
 
\t background:#000; 
 
}
<div class="footer"> 
 
    <footer-outlet></footer-outlet> 
 
</div>

寬度ID

#footer { 
 
\t position:fixed; 
 
\t bottom:0; 
 
\t width:100%; 
 
\t height:100px; 
 
\t background:#000; 
 
}
<div id="footer"> 
 
    <footer-outlet></footer-outlet> 
 
</div>

+0

感謝您的輸入。在.class的情況下不工作在我的結尾,但編號爲 –

+0

您是否在使用角度。你能提供一個演示鏈接嗎? –

+0

#footer { position:fixed; bottom:0; 寬度:100%; height:25px; } -------------------------------- .footerBar { /* width:400px; */ height:25px; 寬度:95%; mrgin-left:0px; margin-right:0px; /* margin:0px; */ font-size:13px; font-weight:bold; /* border-radius:10px; */ background-color:#000000; text-align:center; /* z-index:1000; */ /* margin-left:65px; */ /* margin-right:15px; */ } -------------- -------------------------

1

我所看到的問題是,在類名,用footerBar代替footer

body{ 
 
    height:800px; 
 
} 
 
.footerBar { 
 
    position: fixed; 
 
    bottom: 0; 
 
    width: 100%; 
 
    height: 25px; 
 
    background:#000; 
 
}
<div class="footerBar"> 
 
    <label class="control-label" style="color: white">Copyright 2007-2017</label> 
 
    <label class="control-label" style="float: right;margin-right: 10px;font-weight: bold;color: white">{{version}}</label> 
 
</div>

1

根據你的問題,你是不是在你的html中使用正確的class,它的在css。 正因爲如此,頁腳中的樣式才得以應用。

錯誤:在html中使用footerBar

更正:(或者兩個)

  1. 使用.footerhtml,已經在CSS樣式屬性。
  2. 修改CSS中的類.footerBar,以便它表示與html的相同。

爲什麼id在工作?

id正在工作,因爲你已經在html和css中使用相同和正確的id名稱。

請參考link,它工作得很好。