2017-01-23 6 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 id="footer"><!-- calling of class for footer doesn't work for me here --> 
    <footer-outlet></footer-outlet> 
</div> 
+0

私にリンクを教えてください。 –

+0

あなたのhtmlごとに '.footer'の代わりに' .footerBar'を使うべきです –

+0

おそらくクラスルールをオーバーロードするいくつかの他のCSSルールがありますか?一部のブラウザ開発コンソールでプロパティの評価方法を確認しようとしましたか? – Massimo

答えて

1

に従うように私は別のdivにdiv要素を使用しています細かい

.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が動作していないのに、idが動作する –

+0

あなたは角度を使って作業していますか?あなたはデモリンクを提供できますか? –

+0

#footer { 位置:固定; bottom:0; 幅:100%; 身長:25px; } -------------------------------- .footerBar { /* width:400px; */ 身長: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

私の代わりに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
footerBarを使用し、問題はクラス名である見ることができるようにあなたの質問によると、 ではないあなたのhtmlで正しい classを使用しています。に styleがあります。 これが原因で、フッターのスタイルが適用されません。

エラー:footerBarをHTMLで使用しています。

訂正:html(2のいずれか)

  1. 使用.footer、CSSでスタイルのプロパティを持っています。
  2. CSSのクラスを.footerBarに変更して、htmlと同じになるようにします。

なぜidが機能していたのですか?

idは、htmlとcssの両方に同じと正確なidという名前を使用しているため、動作していました。

linkを参照してください。ここではうまくいきます。

関連する問題