百分比容器内的百分比浮动容器

发布于 2024-10-19 07:56:31 字数 2084 浏览 8 评论 0原文

我有一个简单的问题,我无法弄清楚。看一下这个 html 代码:

    <div id="container">
    <div id="content">
        <div id="menu">
            <ul>
                <li><a href="#" class="active">pagina's</a></li>
                <li><a href="#">home</a></li>
                <li><a href="#">kamers</a></li>
                <li><a href="#">over ons</a></li>
            </ul>
        </div>
        <div class="clearfloats"></div>
        <div id="cmscontent">
            <div id="sidebar">
                <ul>
                    <li><a href="#" class="overzicht active">overzicht van de pagina's</a></li>
                    <li class="last"><a href="#" class="toevoegen">pagina toevoegen</a></li>
                </ul>
            </div>
            <div id="main">
                <h1 class="maintitle">
                    overzicht van de pagina's
                </h1>
                <div id="maincontent">
                    sdfsd
                </div>
            </div>
            <div class="clearfloats"></div>
        </div>
    </div>
</div>

CSS:

#container {
width: 84%;
margin: 0 auto;
}

#content {
margin-top: 50px;
min-width: 1140px;
}

#cmscontent {
background-color: #ffffff;
border: 1px solid #e0e0e0;
padding: 44px 30px 44px 30px;
position: relative;
z-index: 3;
}

#sidebar{
padding: 14px 24px 14px 24px;
width: 306px;
background-color: #f8f8f8;
float: left;
}

#main {
float: left;
margin-left: 80px;
width: 100%;
}

问题是最后一个容器:#main, standard 的宽度仅与其内容一样宽。所以我必须为其添加固定宽度(px)。我设计的重点是我有浮动的百分比 div,所以这是一个无赖。在 % 中添加 100% 宽度或任何其他数字,也有其自身的问题..

有人可以为我提供解决方案吗?

谢谢你!

http://www.mathijsdelva.be/cms/

我还没有微调任何东西;目前我只对 Safari 进行了 html 处理。

I have a simple problem which i cannot figure out. Look at this html code:

    <div id="container">
    <div id="content">
        <div id="menu">
            <ul>
                <li><a href="#" class="active">pagina's</a></li>
                <li><a href="#">home</a></li>
                <li><a href="#">kamers</a></li>
                <li><a href="#">over ons</a></li>
            </ul>
        </div>
        <div class="clearfloats"></div>
        <div id="cmscontent">
            <div id="sidebar">
                <ul>
                    <li><a href="#" class="overzicht active">overzicht van de pagina's</a></li>
                    <li class="last"><a href="#" class="toevoegen">pagina toevoegen</a></li>
                </ul>
            </div>
            <div id="main">
                <h1 class="maintitle">
                    overzicht van de pagina's
                </h1>
                <div id="maincontent">
                    sdfsd
                </div>
            </div>
            <div class="clearfloats"></div>
        </div>
    </div>
</div>

CSS:

#container {
width: 84%;
margin: 0 auto;
}

#content {
margin-top: 50px;
min-width: 1140px;
}

#cmscontent {
background-color: #ffffff;
border: 1px solid #e0e0e0;
padding: 44px 30px 44px 30px;
position: relative;
z-index: 3;
}

#sidebar{
padding: 14px 24px 14px 24px;
width: 306px;
background-color: #f8f8f8;
float: left;
}

#main {
float: left;
margin-left: 80px;
width: 100%;
}

The problem is that the last container: #main, standard is only as wide as the content it has. So i'm obliged to add a fixed width to it (px). The whole point of my design is that i have floating percentual divs so that's a bummer. Adding 100% width or any other number in %, also has problems of its own..

Is there anyone that a solution for me?

Thank you!

http://www.mathijsdelva.be/cms/

I haven't finetuned anything; i only just html'ed for Safari as of the moment.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

樱&纷飞 2024-10-26 07:56:31

问题是最后一个容器:#main, standard 的宽度仅与其内容一样宽。

尝试使用 display: block for #main 吗?

你到底想在这里做什么?你想做出灵活的设计吗?

The problem is that the last container: #main, standard is only as wide as the content it has.

Tried using display: block for #main ?

What are you actually trying to do here? Are you trying to make a flexible design?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文