How can I keep text on a fixed background image while scrolling?
I have a landing page with my site name, sub-title and a button. I set a background image with background-attachment
so that it stays in place when you scroll up.
I want my title, sub-title and button to stay in place so that the overview section overlaps it. I tried to set the text at a fixed position and do z-index: -1
, but it goes behind the background image and appears in the overview section.
https://codepen.io/anon/pen/qmdzzz
The text is wrapped in a intro-text
div
@media (min-width: 768px){
header .intro-text {
padding-top: 300px;
padding-bottom: 200px;
position: fixed;
z-index: -1
}
}
Then I tried to set a higher z index for the overview section
#overview {
z-index: 1000;
}
+3
source to share