如何让此背景图片与页面的其余部分一起滚动? (背景附件:滚动;不起作用。)在滚动之前,我将背景图片和徽标放置在我希望它们保留的位置,但滚动时,徽标和标题滚动,但导航栏和背景图片不滚动。制作CSS背景图片滚动
.content {
overflow: auto;
position: relative;
}
.content:before {
content: "";
position: fixed;
left: 0;
right: 0;
top:-175px;
z-index: -1;
display: block;
background-image: url("/assets/backgroundpic.jpg");
background-size:cover;
background-position:center top;
width: 100%;
height: 500px;
}
<div class="container content text-center" style="position:relative;">
<%= image_tag("/assets/logo-seal.png", size: "250x250", class: "img-responsive img-circle margin", style: "display:inline;margin-top:200px;") %>
<h1 style="font: 48px Oswald, sans-serif;">TITLE</h1>
</div>
谢谢!我将位置更改为绝对位置,并将内容类放在容器外部的div中。我不知道我以前怎么没想到。 – Xenedra