【问题标题】:Fluid fixed block with left margin带有左边距的流体固定块
【发布时间】:2013-01-05 09:33:20
【问题描述】:

我需要在页面上放置固定块。但它应该是流体容器的大小(具有自动左右边距)和容器内的左边距 160px。

HTML

<div id="container">
 <div id="header">Some fixed panel</div>
 Some other scrollable markup
</div>

CSS

#container {
 width: 90%;
 max-width: 1280px;
 padding: 0px 20px 20px 20px;
 margin: 0 auto;
 min-width: 940px;
 position: relative;
 z-index: 1;} 
#header { 
 width: 100%;
 height: 60px;
 position: fixed;
 margin-left: 160px;
 top: 0;
 z-index: 60; }

而且我无法制作固定面板以获得正确的宽度。不知何故,这个块不是从容器获取宽度,而是从窗口获取。

需要一些没有 JS 的解决方案。

Tnx 提前。

【问题讨论】:

  • 使用 jsfiddle 来展示你的问题。
  • jsfiddle.net/only_dimon/5WcgC/18 进行了一些更改以更接近实际项目。固定面板应该是 100% 的容器宽度减去左边距

标签: css css-position fluid-layout


【解决方案1】:

解决了。我使用主容器的边距和宽度的面板的固定包装器。

【讨论】:

    猜你喜欢
    • 2012-07-17
    • 1970-01-01
    • 2015-10-25
    • 2012-09-01
    • 2011-11-03
    • 1970-01-01
    • 2013-07-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多