Hflex and Vflex"
Line 12: | Line 12: | ||
<source lang="xml"> | <source lang="xml"> | ||
<zk> | <zk> | ||
− | + | <datebox/> | |
− | + | <div vflex="1" style="background: yellow"/> | |
</zk> | </zk> | ||
</source> | </source> | ||
Line 25: | Line 25: | ||
<source lang="xml"> | <source lang="xml"> | ||
<div> | <div> | ||
− | + | <datebox/> | |
− | + | <div vflex="1" style="background: yellow"/><!-- height will be zero since height not specified in parent div --> | |
</div> | </div> | ||
</source> | </source> |
Revision as of 04:47, 22 December 2010
Hflex (HtmlBasedComponent.setHflex(String)) and vflex (HtmlBasedComponent.setVflex(String)) indicate the flexibility of the component, which indicates how an component's parent distributes remaining empty space among its children. Hflex controls the flexibility in the horizontal direction, while vflex the vertical direction.
Flexible components grow and shrink to fit their given space. Components with larger flex values will be made larger than components with lower flex values, at the ratio determined by the two components. The actual value is not relevant unless there are other flexible components within the same container. Once the default sizes of components in a box are calculated, the remaining space in the box is divided among the flexible components, according to their flex ratios. Specifying a flex value of 0 has the same effect as leaving the flex attribute out entirely.
Fit-the-Rest Flexibility
The simplest use of flex is to have one component to take the rest of the space of its parent (or the page, if it is the root component). For example,
<zk>
<datebox/>
<div vflex="1" style="background: yellow"/>
</zk>
And, the result
Notice that, if the parent has no predefined height (i.e., its height is decided by this children), the flexible component won't take any space. For example, the inner div (with vflex) takes no space in the following example:
<div>
<datebox/>
<div vflex="1" style="background: yellow"/><!-- height will be zero since height not specified in parent div -->
</div>
To solve it, you have to specify the height in the outer div, such as
,
, or
.
Proportional Flexibility
Minimum Flexibility
Grid's Column and Flexibility
Flexibility versus Percentage
Version History
Version | Date | Content |
---|---|---|