如何使显示:表格单元格宽度:100% - 270px

发布于 2024-12-29 08:07:57 字数 1955 浏览 0 评论 0原文

这是我的代码:

    <div id="banner" style="position:absolute; top:0px; width:100%; background:url('../../images/banner_repeat.jpg'); background-repeat:repeat-x; <!-- border:solid pink 1px; -->"> 
        <ul id="banner_ul">
            <li id="wrm"><a href="http://whiterootmedia.com"><i>The homepage of White Root Media!</i></a></li>
            <li id="google"><a href="https://plus.google.com/u/0/b/115943543157099352927/115943543157099352927" target="_blank"><i>+1 us on Google!</i></a></li>
            <li id="facebook"><a href="http://www.facebook.com/pages/White-Root-Media/194381903928501" target="_blank"><i>Like us on Facebook!</i></a></li>
            <li id="twitter"><a href="http://twitter.com/#!/WhiteRootMedia" target="_blank"><i>Tweet about us on Twitter!</i></a></li>
        </ul>
    </div>

    <div id="container" style="<!-- border:solid yellow 1px -->; display: table;">
        <div id="content" style="padding-top:90px; display:table-cell; min-width:945px; <!-- width:100% - 270px; -->">
            This content will determine the height
        </div>
        <div id="right_column" style="display: table-cell; <!-- border:solid orange 1px; --> height:100%; width:270px; background-image:url('../../images/treetrunk7.png');background-repeat:repeat-y;">tree</div>
    </div>

    <div id="footer" style="position:relative; top:-1px; background-image:url('../../images/grass.png'); background-repeat:repeat-x; width:100%; height:100px;">grass</div>

这是实时页面: http://whiterootmedia.com/test/test4/

我想要显示的内容 div:表格单元格的宽度为页面的整个宽度减去 270px。这棵树应该一直在右边。

非常感谢任何帮助!

谢谢, 尘土飞扬

here's my code:

    <div id="banner" style="position:absolute; top:0px; width:100%; background:url('../../images/banner_repeat.jpg'); background-repeat:repeat-x; <!-- border:solid pink 1px; -->"> 
        <ul id="banner_ul">
            <li id="wrm"><a href="http://whiterootmedia.com"><i>The homepage of White Root Media!</i></a></li>
            <li id="google"><a href="https://plus.google.com/u/0/b/115943543157099352927/115943543157099352927" target="_blank"><i>+1 us on Google!</i></a></li>
            <li id="facebook"><a href="http://www.facebook.com/pages/White-Root-Media/194381903928501" target="_blank"><i>Like us on Facebook!</i></a></li>
            <li id="twitter"><a href="http://twitter.com/#!/WhiteRootMedia" target="_blank"><i>Tweet about us on Twitter!</i></a></li>
        </ul>
    </div>

    <div id="container" style="<!-- border:solid yellow 1px -->; display: table;">
        <div id="content" style="padding-top:90px; display:table-cell; min-width:945px; <!-- width:100% - 270px; -->">
            This content will determine the height
        </div>
        <div id="right_column" style="display: table-cell; <!-- border:solid orange 1px; --> height:100%; width:270px; background-image:url('../../images/treetrunk7.png');background-repeat:repeat-y;">tree</div>
    </div>

    <div id="footer" style="position:relative; top:-1px; background-image:url('../../images/grass.png'); background-repeat:repeat-x; width:100%; height:100px;">grass</div>

here's the live page:
http://whiterootmedia.com/test/test4/

I would like the content div that is display:table-cell to go the full width of the page minus 270px. The tree should be all the way to the right.

Any help is greatly appreciated!

Thanks,
Dusty

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

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

发布评论

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

评论(1

離殇 2025-01-05 08:07:57

您可以在子div的

#foo {
    display: table;
    height: 400px;
    position: relative;
    width: 500px;   
}

#foo > div {
    display: table-cell;
    height: 100%;
    position: absolute;
}

#left {
    background: blue;
    left: 0;
    right: 200px;
}

#right {
    background: green;
    right: 0;
    width: 200px;
}

单击此处进行演示

中使用绝对定位还有其他方法可以实现相同的效果比如改变边距,我个人更喜欢上面的方法

You can use absolute positioning in the child div's

#foo {
    display: table;
    height: 400px;
    position: relative;
    width: 500px;   
}

#foo > div {
    display: table-cell;
    height: 100%;
    position: absolute;
}

#left {
    background: blue;
    left: 0;
    right: 200px;
}

#right {
    background: green;
    right: 0;
    width: 200px;
}

click here for demo

there are other methods of achieving the same effect such as changing the margins, I personally prefer the method above

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