Get a free trial // Grow your CSS skills // Land your dream job

height auto important

  • # March 28, 2013 at 3:58 am

    I am using skeleton framework to do css, i give height:auto!important to a div now when i resize the screen to mobile view it takes same there any way to change the height …..i change the height in media query too but it takes the same height..

    # March 28, 2013 at 4:43 am

    height with !important has always more weight than the other one, that may be the problem , why you use ** !important** ?

    # March 28, 2013 at 5:11 am

    its ie6 and ie7 hack
    div{ min-height:275px; height:auto!important; height:275px; }

    # March 28, 2013 at 5:36 am

    i don’t know the usage of !important

    **min-height:275px** and **height:auto** is enough,**height:275px** is unneccasary i think

    # March 28, 2013 at 8:42 am

    Why are you trying to hack IE6 & 7 for a mobile view? It won’t be found on any mobile device.

    # March 28, 2013 at 10:35 am

    > i don’t know the usage of !important

    It’s called the bang hack. It relies on the inability for Internet Explorer 6 to understand `!important`. Basically, you set whatever you like with the hammerbash flag, then you override it with whatever you like for IE6 only.

    So in our case:

    .my-element {
    height: auto !important;
    height: 275px;

    … results in `height: auto` for everyone except for IE6 which will apply `height: 275px`.

    Problem with this hack is it may involve some specificity problems.

    # March 28, 2013 at 11:54 am

    Perfect example why any type of hacks should be avoided as much as possible.

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.

There's a whole bunch of content on CSS-Tricks.

Search for Stuff   •   Browse the Archives

Get the Newsletter ... or get the RSS feed