html - CSS Parallax background on scroll with CSS and without javascript -
i have page parallax scrolling background uses css (plunkr) can't figure out way keep background content strictly within red boxes.
in short, i'm looking achieve similar effect scrolling background images this one. note there multiple pictures framed within each segment scroll more emulate 3d depth effect.
now know possible javascript of course, after pondering whether achieved trick of of coordinate systems found this example. unfortunately author didn't explain work basic technique use transform: translatez()
achieve depth without emulation hack , playing tricks coordinate system of scrolling sections.
here's code plunkr;
<div class="slidewrapper"> <div id="slide1img" class="slideimg"></div> <div id="slide1" class="slide"> start text... end <div class="footer"> footer text - picture should based above line </div> </div> </div> <div class="slidewrapper"> <div id="slide2img" class="slideimg"></div> <div id="slide2" class="slide"> start2 different text ...some end2 <div class="footer"> footer text - picture should based above line </div> </div> </div>
with
html { overflow: hidden; /* hide normal page scrollbar */ }
body { overflow-x: hidden; overflow-y: scroll; /* replaces usual scrollbar turned off 3d transforms */ -webkit-perspective: 1px; -webkit-transform-style: preserve-3d; -webkit-perspective-origin: top; } .footer { background-color: #eee; border: 1px solid blue; } .slidewrapper { position: relative; /* coord stop */ } .slide { font-size: 200%; border: 1px solid red; } #slide1img { background-image: url("http://www.kennethprimrose.co.uk/wp-content/uploads/2011/06/scottish-landscape..jpg"); -webkit-transform: translatez(-1px) scale(2) translatey(0%); } #slide2img { background-image: url("https://encrypted-tbn1.gstatic.com/images?q=tbn:and9gcsadciz_y-14v-z5q-nm843xz69glr5glv19dzcjtqkjbcd7qc0"); -webkit-transform: translatez(-1px) scale(2) translatey(50%); /* hack */ } .slideimg { content: ""; position: absolute; top: 0; bottom: 0; left: 0; right: 0; z-index: -1; background-position: 50% 50%; background-size: cover; }
there 2 'sections' defined red boxes, each footer. images supposed move on scroll within red boxes that's closest able today.
i'm posting question here in hope collectively community may able take solution further...
Comments
Post a Comment