как попросить div не занимать место с помощью css - PullRequest
0 голосов
/ 09 ноября 2010

ниже показан CSS, который я использую, да, это не профессиональный, я новичок в отношении CSS.

Я хочу написать какое-то свойство в CSS, чтобы div занимал только необходимую ширину, а не больше.

то есть свойство ширины, установленное как ширина: 60%; etc занимает 20%, даже если контроль внутри него или текст внутри него не такой длинный. как сказать "привет" в div занимает еще 60% !!!

1007 * CSS * #form1 { padding: 0px 0px 0px 0px; margin: 0px; display:inline-block; width:100%; font-family: Times New Roman; font-size: 2em; } #container { margin: 0 auto; width: 100%; /*background-color: Yellow;*/ /* for testing*/ } #header { background: #ccc; padding: 20px; /*remove as needed*/ color: Blue; text-align:center; } #navigation { float: left; width: 100%; background: White;/* black*/ color:White; font-size: smaller; } #ul { margin: 0; padding: 0; } #link { list-style-type: none; display: inline; } /* for url one */ #url1 { float: left; padding: 0px 5px 0px 5px; border-right: 1px solid #fff; background-color: White; } #url1 a { float: left; color: Black; text-decoration: none; } #url1 a:hover { background-color:ButtonShadow; color:Highlight; text-transform:uppercase; font-size:xx-large; } /*for url one ends*/ #content-container1 { padding-top:5px; float: left; width: 100%; /*background: #fff url(/wp-content/uploads/layout-three-liquid-background1.gif) repeat-y 20% 0;*/ } #content-container2 { float: left; width: 100%; /*background: url(/wp-content/uploads/layout-three-liquid-background2.gif) repeat-y 80% 0;*/ } #section-navigation { float: left; width: 16%; border-right-color:White; border-right-style:solid; border-right-width:thin; /*background: gray;*/ /* for testing */ display: inline; } #leftul { margin: 0; padding: 0; } #leftlink { padding-left:0.2em; list-style-type: none; /*background-color: Yellow;*/ /*for testing */ } #leftlink a { color: Aqua; text-decoration: underline; } #content { border-left-color: White; border-left-style:solid; border-left-width:thin; float: left; width: 56%; } #aside { float: right; width: 16%; padding: 20px 0; margin: 0 2% 0 0; display: inline; } #aside h3 { margin: 0; } #footer { clear: both; background: #ccc; text-align: right; padding: 20px; height: 1%; } .symbols { font-family: Webdings; } и картинка

alt text

HTML, как показано на ie6

<!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>

1 Ответ

1 голос
/ 09 ноября 2010

попробуйте этот стиль

.asNarrowAsPossible
{
   width:1%; /* encourages the container to be very narrow */
   white-space: nowrap; /* forces the content to one line*/
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...