Grow your CSS skills. Land your dream job.

Set div width issue in IE7

  • # April 30, 2013 at 11:38 am

    Hi all,

    I’m facing a css issue. In IE7, I set a div width to “auto” to set the div width according to the div content. But it does not work. IE8 works fine. All css property I set in the div are

    /* Inline properties */
    left: 571px;
    top: 310px;
    overflow: hidden;
    margin-top: 0px;
    margin-left: -22px;
    display: block;
    filter: alpha(opacity=1);
    position: absolute;
    z-index: 311;

    /* style applied using a class */
    .labels
    {
    color: red;
    background-color: white;
    font-family: “Lucida Grande” , “Arial” , sans-serif;
    font-size: 10px;
    font-weight: bold;
    text-align: center;
    border: 2px solid black;
    white-space: nowrap;
    z-index: 8768;
    opacity: 1;
    min-width: 30px;
    width: auto;
    filter: alpha(opacity = 100) !important;
    }

    For reasons, I could not change Inline properties( position, overflow, top, left, zIndex, display, marginLeft, and marginTop).

    If I remove width or minwidth, div width became 0. div width change with the value of minwidth or width. But I want that div width should change with it’s content.

    Any help on this is much appreciated.

    # April 30, 2013 at 10:37 pm

    This isn’t an answer but a reason why IE7 should be dropped from your browser list, currently global statistics show IE8 at around 9% of all web traffic which is extremely low and IE7 is even lower at 2-3% of all web traffic. Considering how low these numbers are I would personally set the baseline as IE9 as the chances someone visiting your website in IE 7/8 is extremely low as around 95-98% of corporations in the world use them still use them.

    From a consumer level you would see higher traffic sources coming from Google Chrome, Firefox, Safari and IE9+

    # May 1, 2013 at 1:23 am

    That’s true. But what to do if your client still using IE7.

    # May 1, 2013 at 8:04 am

    ok..finally the issue is solved by setting the style “overflow: visible !important” for the “labels” class.

    .labels
    {
    /*………previous styles………..*/

    overflow: visible !important
    }

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

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".