Hi!
I have noticed something strange: I have an element styled to have padding,
a border and some margin. The element contains preformatted text. When the
browser window is made narrow enough, a horizontal scrollbar appears as the
preformatted text becomes too wide and is not wrapped. So far so good. But
why is the element itself shrunk to fit in the window (still having its full
margin, padding and border visible) as if it's content was not too wide?
Instead of staying "around" the preformatted text (i.e. fully enclosing it),
the latter seems to "overflow" the element's boundaries. This also seems to
happen with other content (like an image). Is this standard behaviour? Or
should I look for what I must have done wrong?
Illustration:
* = window edge
+---+
! ! = element border
+---+
##::: = scrollbar
Window wide enough:
* +----------+ *
* ! ! *
* ! ABCDEFGH ! *
* ! ! *
* +----------+ *
Window not wide enough:
- That's what I expect:
* +------*----+
* ! * !
* ! ABCDE*FGH !
* ! * !
* +------*----+
######::::
- But that's what happens:
* +----+ *
* ! ! *
* ! ABCDE*FGH
* ! ! *
* +----+ *
######::::
Confused,
Thomas
I have noticed something strange: I have an element styled to have padding,
a border and some margin. The element contains preformatted text. When the
browser window is made narrow enough, a horizontal scrollbar appears as the
preformatted text becomes too wide and is not wrapped. So far so good. But
why is the element itself shrunk to fit in the window (still having its full
margin, padding and border visible) as if it's content was not too wide?
Instead of staying "around" the preformatted text (i.e. fully enclosing it),
the latter seems to "overflow" the element's boundaries. This also seems to
happen with other content (like an image). Is this standard behaviour? Or
should I look for what I must have done wrong?
Illustration:
* = window edge
+---+
! ! = element border
+---+
##::: = scrollbar
Window wide enough:
* +----------+ *
* ! ! *
* ! ABCDEFGH ! *
* ! ! *
* +----------+ *
Window not wide enough:
- That's what I expect:
* +------*----+
* ! * !
* ! ABCDE*FGH !
* ! * !
* +------*----+
######::::
- But that's what happens:
* +----+ *
* ! ! *
* ! ABCDE*FGH
* ! ! *
* +----+ *
######::::
Confused,
Thomas
Comment