css - Flexbox: How to Combine percent, pixels and remaining height on columns? -
I am creating a basic grid system and adding the height of the Flex objects described in different size units, which is% Px And the rest of the place
html:
& lt; Div class = "grid" & gt; & Lt; Div class = "block" style = "flex-basis: 50px;" & Gt; 50px & lt; / Div & gt; & Lt; Div class = "block" style = "flex-base: 25%;" & Gt; 25% & lt; / Div & gt; & Lt; Div class = "block" & gt; Stretch for the rest of the place? & Lt; / Div & gt; & Lt; Div class = "block" style = "flex-basis: 50px;" & Gt; 50px & lt; / Div & gt; & Lt; / Div & gt; CSS:
html, body, .grid {height: 100%; Padding: 0; Margin: 0; } .grid {width: 300px; Background: #aaa; Exhibit: Flex; Flex-direction: column; Appropriate Materials: Flex-Start; } .block {outline: solid 1px black; Extend Flex: 0; // Flex-shrink to the growing ratio: 0; // Exclude Remove Ratio} Example:
< P> Use
to increase flex parameter ( flex first in the shortened property): HTML:
Lt; Div class = "grid" & gt; & Lt; Div class = "block a" & gt; Block Height 50px & lt; / Div & gt; & Lt; Div class = "block b" & gt; Block height 25% & lt; / Div & gt; & Lt; Div class = "block c" & gt; Block Height * & lt; / Div & gt; & Lt; Div class = "block d" & gt; Block Height 50px & lt; / Div & gt; & Lt; / Div & gt; CSS:
.block {outline: solid 1px black; }. a,. D {Flex: 0 50px; }. B {Flex: 0 25%; }. C {Flex: 0; }
Comments
Post a Comment