gpt4 book ai didi

html - 图像 CSS 下的内容流

转载 作者:太空宇宙 更新时间:2023-11-03 18:40:55 25 4
gpt4 key购买 nike

好的,我的背景有一个清晰的区域,里面有平衡的内容,我希望它在用户向上滚动时滑到图像顶部下方。我有一个 jsfiddle,请原谅我草率的 CSS,我一直在尽一切努力让它工作。我还有一个 float 导航栏,它也应该滑到下面。

http://jsfiddle.net/CFFwA/

@charset "UTF-8";
/* CSS Document */
html,body {
height:100%;
width:100%;
}

body{
background-image:url(images/1920w.png);
background-size:100%;
background-position:center;
background-attachment:fixed;
background-repeat:no-repeat;
background-color:#E9C9A0;
z-index:5;
}

#bod{
width:100%;
height:100%;
background-image:url(images/1920w.png);
background-size:100%;
background-position:center;
background-attachment:fixed;
background-repeat:no-repeat;
left:0;
z-index:20;
}

#bann{

width:62.5%;
height:100%;
z-index:10;
}


#head{
position:fixed;
margin-top:8.5%;
margin-right:18.75%;
margin-left:18.75%;
width:62.5%;
height:100%;
z-index:32;
}

#content{
padding-top:14%;
width:62.5%%;
height:100%;
margin-left:auto;
margin-right:auto;
z-index:4;
}

最佳答案

一个简单的解决方法是使用 position:fixed

使您的图像成为一个单独的元素

HTML

<img src="/path/to/bg.png" id="body-bg" />

CSS

#body-bg {
width: 100%;
position: fixed;
top: 0;
}

Check the fiddle

关于html - 图像 CSS 下的内容流,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17627057/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com