Reputation: 1107
Does the CSS property overflow
apply to div
s, 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
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
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;">
* most: block-level elements, table cells, inline-table and inline-block elements. Documentation here.
Upvotes: 1
Reputation: 498972
overflow
applies to block level elements.
Span is an inline element (as is img
), so it will not apply.
Upvotes: 1