Stylesheet 如何使用css要求div不要占用空间

Stylesheet 如何使用css要求div不要占用空间,stylesheet,webpage,Stylesheet,Webpage,下面显示了我正在使用的css,是的,它不是专业的,我是css的初学者 我想在css中写一些属性,这样div只占用所需的宽度,而不是更多 即宽度属性设置为宽度:60%;即使其中的控件或文本没有那么长,etc也会占用20%。喜欢在div中说“嗨”仍然占60% css 照片呢 ie6显示的html 来自代码标签的标题 左侧 这是页面的中心 试试这种风格 .asNarrowAsPossible { width:1%; /* encourages the container to be very

下面显示了我正在使用的css,是的,它不是专业的,我是css的初学者

我想在css中写一些属性,这样div只占用所需的宽度,而不是更多

即宽度属性设置为宽度:60%;即使其中的控件或文本没有那么长,etc也会占用20%。喜欢在div中说“嗨”仍然占60%

css 照片呢

ie6显示的html

来自代码标签的标题
左侧
这是页面的中心
试试这种风格

.asNarrowAsPossible
{
   width:1%; /* encourages the container to be very narrow */
   white-space: nowrap; /* forces the content to one line*/
}

你不能同时添加HTML代码吗?那会有很大帮助。但是,您可以尝试宽度:自动;然后查看结果。没有自动宽度,这只会破坏布局。你为什么要提出这个?可能是我错了,但它破坏了格式,所有div一个接一个地出现在一起将不限制其宽度,如果宽度为autocnt,则我需要包装功能,因此即使屏幕大小调整到任何级别,数据仍保留在可见部分
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>

</title><link rel="stylesheet" type="text/css" href="LAYOUT1.css" /></head>
<body>
    <form name="form1" method="post" action="DynamicLayout.aspx" id="form1">
<div>
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwULLTE2MTY2ODcyMjlkZOy4VHs0ZOF6zRS6A7E09eCqf5GY" />
</div>

<div>

    <input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEWAgKFjacpAqDAiY0LQudCxpijJWZK6qWohE+SufqyOGA=" />
</div>
    <div>
    </div>

    <div id="container" runat="server">
    <div id="header" runat="server">
        <span>The header from code label</span><input name="ctl03" type="text" value="This is the text box" />
    </div><div id="navigation" runat="server">
        <div id="ul" runat="server">
            <div id="link" runat="server">
                <div id="url1" runat="server">
                    <a class="symbols" href="#">H</a>
                </div><div id="url2" runat="server">
                    <a href="#">About</a>
                </div>
            </div>
        </div>
    </div><div id="content-container1" runat="server">
        <div id="content-container2" runat="server">
            <div id="section-navigation" runat="server">
                <div id="leftul" runat="server">
                    <div id="leftlink" runat="server">
                        LEFT SIDE
                    </div>
                </div>
            </div><div id="content" runat="server">
                This is the center of the page
            </div>
        </div>
    </div>
</div></form>
</body>
</html>
.asNarrowAsPossible
{
   width:1%; /* encourages the container to be very narrow */
   white-space: nowrap; /* forces the content to one line*/
}