CSS: OverFlow, Scrolling Box

By Xah Lee. Date: . Last updated: .

CSS has a overflow attribute. It creates a scroll bar when the element is larger than its container box.

Here's a example:

Alice was beginning to get very tired of sitting by her sister on the bank, and of having nothing to do: once or twice she had peeped into the book her sister was reading, but it had no pictures or conversations in it, «and what is the use of a book,» thought Alice «without pictures or conversation?».

whether the pleasure Trade-offs, whose general study is called Economics. To illustrate: Everyone wants to be millionaire when asked, but if you have to pay, the question is: “How Much?”. White Rabbit There's a 1960's song by Grace Slick called White Rabbit, based on Wonderland themes. See White Rabbit. See also Wikipedia White Rabbit.

So she was considering in her own mind (as well as she could, for the hot day made her feel very sleepy and stupid), whether the pleasure of making a daisy-chain would be worth the trouble of getting up and picking the daisies, when suddenly a White Rabbit with pink eyes ran close by her.

Here's the HTML code:

<div class="x88088">
<p>Alice was …</p>

<p>…</p>

<p>…</p>
</div>

Here's the CSS code:

div.x88088 {
width:50%;
height:9em;
overflow:auto;
}

〔►see CSS: Units

Overflow Attributes

syntax/attributepurpose
overflow:visible default. Content may be rendered outside the container element.
overflow:hidden Content are clipped.
overflow:scrollshow both horizontal and vertical scroll bars when content is larger than the container box.
overflow:autoshow vertical or horizontal scroll bar as necessary
overflow:inheritinherit parent.

Reference

Like what you read? Buy JavaScript in Depth
or, buy a new keyboard, see Keyboard Reviews.