Footerを画面の1番下に配置したいが固定したくないです。
<!DOCTYPE html> <html lang="ja"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <script src="https://code.jquery.com/jquery-3.1.0.min.js"></script> <style> body , html { height: 100%; } #container { width: 100%; position: relative; height: auto !important; height: 100%; min-height: 100%; background-color: yellow; } #contents { padding-bottom: 100px; background-color: blue; } #footer { position: fixed; bottom: 0; width: 100%; height: 100px; background-color: red; } </style> </head> <body> <div id="container"> <div id="header">ヘッダー</div> <div id="contents">コンテンツ</div> <div id="footer">フッター</div> </div> </body> </html>
とコードを書きました。
今の状態で実行すると、コンテンツの要素がどんなに増えてもフッターが常に画面に表示されます。
フッターを常に画面に表示はせず、一番下にスクロールした時のみフッターを表示させたいです。その時フッターは画面の一番下にぴったり配置させたいです。
position: fixed;
がその役割をしているとは思うのですが、これをつけるとフッターが固定されてしまいます。
どのようにcssを書き換えれば目的の画面が得られますか?

回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。