The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Home › Forums › CSS › height to auto
Hi I have a problem setting the height to auto, so that the background image display in its entirety, met someone with such a problem?
<style type="text/css"> #box{ max-width: 630px; } .first1{ background-image: url( smartplug_scene_eu.jpg); background-repeat: no-repeat; background-position: top left; width: 100%; height: auto; margin: 0px; } </style> <div> <div> </div> </div>
That’s not the way it works. The image will take the size of the div, not the other way round.
Without content in the div, height:auto just means zero.
height:auto
I know but if we can work around it somehow because I’m interested in the image to fit the width and height not
Then you need javascript to get the image’s dimensions and apply that to the div.
Without any height the div will collapse and the image won’t show.
I’m really not clear on what you are trying to do…