Problem with width:auto;

#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?

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.]

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).

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.

Thank you, i use of this and worked.

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 :slight_smile: