flexboxを使用してフルハイトアプリを使用したい。私display: box;
はこのリンクで古いflexboxレイアウトモジュール(およびその他のもの)を使用して欲しいものを見つけました:CSS3 Flexboxフルハイトアプリとオーバーフロー
これは、古いバージョンのフレックスボックスCSSプロパティのみをサポートするブラウザーに適したソリューションです。
新しいフレックスボックスのプロパティを使用したい場合は、ハックとしてリストされているのと同じリンクで2番目のソリューションを使用してみますheight: 0px;
。縦スクロールを表示します。
他の問題が発生し、解決策よりも回避策であるため、あまり好きではありません。
html, body {
height: 100%;
}
#container {
display: flex;
flex-direction: column;
height: 100%;
}
#container article {
flex: 1 1 auto;
overflow-y: scroll;
}
#container header {
background-color: gray;
}
#container footer {
background-color: gray;
}
<section id="container" >
<header id="header" >This is a header</header>
<article id="content" >
This is the content that
<br />
With a lot of lines.
<br />
With a lot of lines.
<br />
This is the content that
<br />
With a lot of lines.
<br />
<br />
This is the content that
<br />
With a lot of lines.
<br />
<br />
This is the content that
<br />
With a lot of lines.
<br />
</article>
<footer id="footer" >This is a footer</footer>
</section>
基本的な例でJSFiddleも用意しました:http ://jsfiddle.net/ch7n6/
これはフルハイトのHTML Webサイトであり、フッターはコンテンツ要素のflexboxプロパティのために下部にあります。CSSコードと結果の間でバーを移動して、異なる高さをシミュレートすることをお勧めします。
flex-shrink:0
ヘッダーとフッターの両方に適用する必要があります。