collapsedMarginBottom property
double
get
collapsedMarginBottom
Implementation
double get collapsedMarginBottom {
double marginBottom;
// Margin is invalid for inline element.
if (effectiveDisplay == CSSDisplay.inline) {
marginBottom = 0;
return marginBottom;
}
// Margin collapse does not work on following case:
// 1. Document root element(HTML)
// 2. Inline level elements
// 3. Inner renderBox of element with overflow auto/scroll
if (isDocumentRootBox() || (effectiveDisplay != CSSDisplay.block && effectiveDisplay != CSSDisplay.flex)) {
marginBottom = this.marginBottom.computedValue;
return marginBottom;
}
if (!isNextSiblingAreRenderObject()) {
// Margin bottom collapse with its parent if it is the last child of its parent and its value is 0.
marginBottom = _collapsedMarginBottomWithParent;
} else {
// Margin bottom collapse with its nested last child when meeting following cases at the same time:
// 1. No padding, border is set.
// 2. No height, min-height, max-height is set.
// 3. No block formatting context of itself (eg. overflow scroll and position absolute) is created.
marginBottom = _collapsedMarginBottomWithLastChild;
}
return marginBottom;
}