2013-02-24 54 views
1

很难解释,一张图片(在这种情况下是两个)值1000字。CSS有可能使滚动元素不显示在窗口的顶部

我有

  • 全图像背景,

  • 固定报头与在这里表示在下面的固体橙色导航栏,

  • 在透明黄色这里表示如下一些滚动内容。

我希望可滚动的元素不会显示在橙色条的上方,以便它不会显示在屏幕的顶部100像素。这能实现吗?

背景中的形象,这是一个形象不是身体的背景下,有以下样式:

#full-screen-background-image { 
    z-index: -999; 
    min-height: 100%; 
    min-width: 1024px; 
    width: 100%; 
    height: auto; 
    position: fixed; 
    bottom: 0; 
    left: 0; 
} 

the elements undesired effect

+0

你想让内容隐藏或停止滚动吗?只要在黄色内容区域应用“margin-top”,怎么样? – danijar 2013-02-24 21:47:07

+1

如何将橙色标题上方的背景部分作为单独图像进行复制,并将其z-索引在黄色内容上方。这样,当黄色内容向上滚动时,它会被图像覆盖。这是否符合你的要求? – 2013-02-24 21:49:36

+0

@TimGoodman我想过,但背景图像调整窗口宽度,图像是最小高度:100%; min-width:1024px;宽度:100%; – kaklon 2013-02-24 21:59:00

回答

0

http://jsfiddle.net/chrisdanek/TNRkY/1/检查出这个小提琴

HTML结构是非常基本的,我刚刚添加了一个包装到内容。它有position :fixedoverflow: auto,所以它允许内容滚动。

.bg { 
    position: fixed; 
    z-index: -1; 
    top: 0; 
    left: 0; 
    bottom: 0; 
    right: 0; 
    background: #cfc; 
} 
.toolbar { 
    position: fixed; 
    z-index: 100; 
    top: 100px; 
    left: 0; 
    right: 0; 
    height: 50px; 
    background: #fcc; 
} 
.wrap { 
    position: fixed; 
    z-index: 50; 
    overflow: auto; 
    top: 150px; 
    left: 0; 
    bottom: 0; 
    right: 0; 
} 
.content { 
    background: #ffc; 
    margin-top: 50px; 
} 
+0

有一件事 - 如果你想让滚动条显示整个窗口的高度,只需将'.wrap'的最高值设置为0并将'margin-top:200px'添加到'.content'。 – 2013-02-25 09:38:40

+0

感谢您的建议,但由于滚动条并未进入窗口的顶部,它会混淆页面元素的对齐。我想我将不得不改变我的设计理念。 – kaklon 2013-02-26 21:48:16

相关问题