Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS height to auto

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #200277
    crenos
    Participant

    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>
    
    #200294
    Paulie_D
    Member

    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.

    #200301
    crenos
    Participant

    I know but if we can work around it somehow because I’m interested in the image to fit the width and height not

    #200302
    Paulie_D
    Member

    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…

Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘CSS’ is closed to new topics and replies.