Reputation: 1371
Is there an alternate way to scroll an image with the height set as auto at all? Because I have an image that does not fully fit into the div container and I don't want to force px in the height attribute:
<div style="height: auto; width: 150px; overflow: scroll;">
<img> .....bla bla bla
</div>
Upvotes: 0
Views: 2383
Reputation: 1219
Well you don't have to set the height of the div.
I made you an example with scrolling only the width: http://jsfiddle.net/ah3b20zs/13/
HTML:
<div style="height: auto; width: 150px; overflow-x: scroll;">
<img src="yourimg" alt="caption" />
</div>
P.S.: I used exact witdh within the <img>
because the source image was too big.
If you want to scroll height as well I don't think it's possible without saying from where it should start scrolling(setting height
or max-height
of the div).
So the question for you is: When do you want it to start scrolling?
Upvotes: 2
Reputation: 16
use this your height will be auto
<div style="height: 100%; width: 150px; overflow: scroll;">
also you can add max-height to the code like this max-height:200px;
Upvotes: -1