SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    Non-Member
    Join Date
    Nov 2010
    Posts
    220
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    problem with width:auto;

    Code CSS:
    #main_admin {
        background: #000000;
        width: auto;
        height: 300px;
        margin: 0 0 0 0;
        padding: 0;
        border: 1px solid #1d1d1d;
    }


    to this code width not auto and is 100%.
    i want-> width: auto;
    i not want use position:absolute; or float.
    Do you have idea to solve this problem?

  2. #2
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,200
    Mentioned
    456 Post(s)
    Tagged
    8 Thread(s)
    If you don't set a width, it defaults to auto. I think maybe you need to show the context of this code, and tell us what you want to see.

    [Moved to CSS forum.]

  3. #3
    Community Advisor silver trophybronze trophy
    dresden_phoenix's Avatar
    Join Date
    Jun 2008
    Location
    Madison, WI
    Posts
    2,804
    Mentioned
    34 Post(s)
    Tagged
    2 Thread(s)
    on a block element, width:auto IS 100% with padding included. in order for it to "shrinkwrap" you need to use float, position:absolute OR display:inline ( or inline-block).

  4. #4
    Ripe Tomatos silver trophybronze trophy Rayzur's Avatar
    Join Date
    Jun 2007
    Location
    Texas
    Posts
    4,174
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by binboy View Post
    ... I don't want to use position:absolute; or float.
    Do you have idea to solve this problem?
    Then I would lean towards display:inline-block; since you are setting a height on it.

    As dresden_phoenix mentioned, it is a shrinkwrapping element that will expand to the width of it's content. It is also capable of taking dimensions like a block level element.

  5. #5
    Non-Member
    Join Date
    Nov 2010
    Posts
    220
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you, i use of this and worked.
    Code:
    display: inline-table;

  6. #6
    The CSS Clinic is open silver trophybronze trophy
    Paul O'B's Avatar
    Join Date
    Jan 2003
    Location
    Hampshire UK
    Posts
    40,367
    Mentioned
    180 Post(s)
    Tagged
    6 Thread(s)
    Quote Originally Posted by binboy View Post
    Thank you, i use of this and worked.
    Code:
    display: inline-table;
    Note that inline-table won't work for IE7 and under though so inline-block may have been a better choice as there is a hack to make it work in IE7 and under also - if you are interested


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •