2017-01-23 48 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,它工作得很好。