固定ヘッダーとスクロール可能なコンテンツ領域を持つWebページを作成しようとしています。ヘッダーが既知の高さを持っている場合はこれは簡単ですが、ヘッダーが流動しているときの解決策を見つけるのには苦労しています。CSSを使用して固定可変高さヘッダーとスクロール可能なコンテンツボックスを配置するにはどうすればよいですか?
私が望むレイアウトは次のとおりです。
「頭」は、それはそれがために、コンテンツのニーズ何でも高さであり、「コンテンツ」とは何の最小の高さを持っていませんが、ビューポートの一番下の最大の高さに到達します--------------
head
--------------
content
--------------
スクロール可能になる前に
これは最近の純粋なCSSで可能でしょうか?私はIE8 +をターゲットにしています。私が欲しいものを明確にするために
、here is what I would do if I knew the height of the header:position:fixed
は、文書フローのうちの要素を取るとして、あなたがposition:fixed
を意味する「固定」で仮定し
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
body {
margin: 0;
}
#head {
background: yellow;
height: 20px; /* I can't rely on knowing this. */
}
#content {
background: red;
position: absolute;
top: 20px; /* here also */
bottom: 0;
width: 100%;
overflow: auto;
}
</style>
</head>
<body>
<div id="head">some variable height content</div>
<div id="content">
scrollable content<br/>
scrollable content<br/>
scrollable content<br/>
scrollable content<br/>
scrollable content<br/>
scrollable content<br/>
scrollable content<br/>
scrollable content<br/>
scrollable content<br/>
scrollable content<br/>
scrollable content<br/>
scrollable content<br/>
scrollable content<br/>
scrollable content<br/>
scrollable content<br/>
</div>
</body>
</html>
スクロールバーをコンテンツの横に、またはページ全体の高さに沿ってしますか? – Eric
ヘッダーが「固定」の場合、どのように高さが液体ですか? – Eric
スクロールバーは、コンテンツの横にあるのが理想的です。私が固定したと言ったとき、私は定位置にいた。メインコンテンツでスクロールしません。 –