alt.126
alt.126

Reputation: 1107

CSS "overflow" property for elements other than DIVs

Does the CSS property overflow apply to divs, or is there a list of other HTML elements that support this property?

I tried to use:

<span style="overflow:auto;"><img src="hs.gif" alt="Horizontal Scroll"></span>

But it doesn't seem to apply an horizontal scroll bar when the contents are partially hidden, as in the case of a div.

Upvotes: 0

Views: 206

Answers (3)

rOcKiNg RhO
rOcKiNg RhO

Reputation: 631

**Initial value:visible

Applies to: block and inline-block elements, table cells

Inherited : no

Media:visual

Computed value as specified**

for more details https://developer.mozilla.org/en-US/docs/CSS/overflow

Upvotes: 1

Ry-
Ry-

Reputation: 224905

It works on most* elements; the problem is that your <span> expands to contain your image. (What width would it need for there to be a scrollbar?) Give it a width (and to do that, it can't be inline, either; the default for <span>s):

<span style="overflow: auto; display: inline-block; width: 100px;">

And now it works.

* most: block-level elements, table cells, inline-table and inline-block elements. Documentation here.

Upvotes: 1

Oded
Oded

Reputation: 498972

overflow applies to block level elements.

Span is an inline element (as is img), so it will not apply.

Upvotes: 1

Related Questions