设置div的宽度直到浏览器端

时间:2013-02-16 19:57:14

标签: html css

我从两个例子开始:

13“macbook pro: macscreen 21“飞利浦显示器 philipscreen

是否可以使用position:fixed为父元素设置全宽,但对于子元素,设置宽度直到浏览器网站,因此在所有尺寸中文本将一直到浏览器网站或最大宽度。

CSS:

div#wrapper{
    width: 100%;
    height: 100%;
    padding-top: 70px;
}

header#left-panel, header#right-panel{
    background: none repeat scroll 0 0 #000000;
    min-height: 40px;
    padding: 10px;
    opacity: 0.8;
}

header#left-panel{
    width: 185px;
    position: fixed;
}

header#right-panel{
    /*width: 100%;*/ /*here is the problem*/
    left: 755px;
    position: fixed;
}

HTML:

<body>
    <div id="wrapper">
        <header id="left-panel">
            <section id="contacts">
            </section>
        </header>
        <header id="right-panel">
            <section id="comments">
                <div>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</div>
                <div style="float:right">Lorem ipsum</div>
            </section>
        </header>
    </div>
</body>

2 个答案:

答案 0 :(得分:1)

right:0元素上使用header#right-panel

您可以在this jsFiddle上使用它。

答案 1 :(得分:0)

header#right-panel{
    /*width: 100%;*/ 
    right: -1px;
    position: fixed;
}

应该有效

相关问题