正如我已经提到的,我希望我的背景固定在它的 DIV 中,并且只有要滚动的内容。 我的问题是,每当我将背景属性设置为固定时,背景似乎从页面的开头(0-top)开始,尽管我只将它设置为 div。在我开始向下滚动之前,它不会被修复。
#elections_top
{
position: relative;
width: 890px;
height: auto;
direction: rtl;
}
#elections_top .elections_news
{
position: relative;
width: 890px;
height: auto;
padding-bottom: 90px;
background: url("../images/coca_cola_bg.jpg") #e01b22;
background-repeat: no-repeat;
background-attachment:fixed;
background-position:50% top;
}
elections_news 是相对于 elections_top 的,它出现在站点中的标题之后,背景不知何故似乎是从标题开始放置的
最佳答案
尝试移除background-attachment:fixed;
关于css - 我想让DIV里面的背景固定,只有内容随滚动移动,怎么办?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16997888/