@@ -201,6 +201,17 @@ public virtual bool IsFixed
201201 }
202202 }
203203
204+ /// <summary>
205+ /// Gets a value indicating whether this instance has Position = absolute.
206+ /// </summary>
207+ /// <value>
208+ /// <c>true</c> if this instance is fixed; otherwise, <c>false</c>.
209+ /// </value>
210+ public virtual bool IsAbsolute
211+ {
212+ get => Position == CssConstants . Absolute ;
213+ }
214+
204215 /// <summary>
205216 /// Get the href link of the box (by default get "href" attribute)
206217 /// </summary>
@@ -650,6 +661,26 @@ protected virtual async Task PerformLayoutImpAsync(RGraphics g)
650661 left = 0 ;
651662 top = 0 ;
652663 }
664+ else if ( Position == CssConstants . Absolute )
665+ {
666+ // find the first positioned parent.
667+ CssBox currentParent = ParentBox ;
668+ CssBox positionedAncestor = null ;
669+ while ( currentParent != null && string . IsNullOrEmpty ( currentParent . Position ) )
670+ {
671+ currentParent = currentParent . ParentBox ;
672+ }
673+ positionedAncestor = currentParent ;
674+
675+ if ( positionedAncestor != null )
676+ {
677+ var location = GetActualLocation ( this . Left , this . Top ) ;
678+ left = positionedAncestor . Location . X + location . X ;
679+ top = positionedAncestor . Location . Y + location . Y ;
680+
681+ Location = new RPoint ( left , top ) ;
682+ }
683+ }
653684 else
654685 {
655686 left = ContainingBlock . Location . X + ContainingBlock . ActualPaddingLeft + ActualMarginLeft + ContainingBlock . ActualBorderLeftWidth ;
@@ -709,11 +740,11 @@ protected virtual async Task PerformLayoutImpAsync(RGraphics g)
709740 ActualBottom = prevSibling . ActualBottom ;
710741 }
711742 }
712- ActualBottom = Math . Max ( ActualBottom , Location . Y + ActualHeight ) ;
713743
744+ ActualBottom = Math . Max ( ActualBottom , Location . Y + ActualHeight ) ;
714745 await CreateListItemBoxAsync ( g ) ;
715746
716- if ( ! IsFixed )
747+ if ( ! IsFixed && ! IsAbsolute )
717748 {
718749 var actualWidth = Math . Max ( GetMinimumWidth ( ) + GetWidthMarginDeep ( this ) , Size . Width < 90999 ? ActualRight - HtmlContainer . Root . Location . X : 0 ) ;
719750 HtmlContainer . ActualSize = CommonUtils . Max ( HtmlContainer . ActualSize , new RSize ( actualWidth , ActualBottom - HtmlContainer . Root . Location . Y ) ) ;
@@ -1192,12 +1223,15 @@ private double CalculateActualRight()
11921223 private double MarginBottomCollapse ( )
11931224 {
11941225 double margin = 0 ;
1226+
1227+ // Get the last child box that doesn't have absolute or fixed positioning.
1228+ var lastChildBox = _boxes . Where ( b => b . Position != CssConstants . Fixed && b . Position != CssConstants . Absolute ) . LastOrDefault ( ) ;
11951229 if ( ParentBox != null && ParentBox . Boxes . IndexOf ( this ) == ParentBox . Boxes . Count - 1 && _parentBox . ActualMarginBottom < 0.1 )
11961230 {
1197- var lastChildBottomMargin = _boxes [ _boxes . Count - 1 ] . ActualMarginBottom ;
1231+ var lastChildBottomMargin = lastChildBox ? . ActualMarginBottom ?? 0 ;
11981232 margin = Height == "auto" ? Math . Max ( ActualMarginBottom , lastChildBottomMargin ) : lastChildBottomMargin ;
11991233 }
1200- return Math . Max ( ActualBottom , _boxes [ _boxes . Count - 1 ] . ActualBottom + margin + ActualPaddingBottom + ActualBorderBottomWidth ) ;
1234+ return Math . Max ( ActualBottom , ( lastChildBox ? . ActualBottom ?? 0 ) + margin + ActualPaddingBottom + ActualBorderBottomWidth ) ;
12011235 }
12021236
12031237 /// <summary>
0 commit comments