Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does an absolute position element wrap based on its parent's right bound?

Tags:

css

Why does an absolutely positioned element depend on its parent for text wrapping? Doesn't position: absolute remove an element from the flow?

Why does this text wrap around, even though this container has been removed from the flow of its parent?

I'm looking to remove this boundary. This is like an implied max-width that I don't want; I want another developer to be able to set this max-width, and not worry about this arbitrary bound. How do I remove this behavior?

For convenience, here is a jsbin.

like image 812
uber5001 Avatar asked Oct 01 '22 12:10

uber5001


1 Answers

Doesn't position: absolute remove an element from the flow?

This has nothing to do with the flow. The width of an element always respects its containing block. If the element is absolutely positioned, then its dimensions can be constrained by top, right, bottom and left, but as long as its width is auto then it must still be constrained to the width of its containing block (making it no different from in-flow block boxes in that respect), which in your case is its absolutely-positioned parent. There isn't really any other element whose constraints the absolutely-positioned element could size itself with respect to without compromising the flow of its text.

For the specifics of how this width is calculated, refer to the spec.

like image 87
BoltClock Avatar answered Oct 04 '22 20:10

BoltClock