I tried to get the parallax effect on the landing page of my site. I used the interactive_bg.js plugin and worked in the opposite direction from the demo tutorial. Finally, I was able to get a snapshot with the desired effect.
Here is my code:
HTML -
<body> <div class="wrapper bg" data-ibg-bg="pics/Q.jpg"> </div> </body>
CSS -
html { height: 100%; } body { padding: 0; text-align: center; font-family: 'open sans'; position: relative; margin: 0; height: 100%; } .wrapper {
Js -
$(document).ready(function(){ $(".bg").interactive_bg({ strength: 20, scale: 1.00, contain: false, wrapContent: true }); }); $(window).resize(function() { $(".wrapper > .ibg-bg").css({ width: $(window).outerWidth(), height: $(window).outerHeight() }) })
I redid the tutorial files to find this code.
Now the problem is that everything I put in <div class="wrapper bg" data-ibg-bg="pics/Q.jpg"> is distorting the image. Any div that I want to put after the div <div class="wrapper bg" data-ibg-bg="pics/Q.jpg"> does not appear even on the screen, but rather behind the background image.
How to put text and other divs in a div <div class="wrapper bg" data-ibg-bg="pics/Q.jpg"> and more after the end of this div?
I tried z-index and positioning (looking at the code from the tutorial). This does not seem to work.
In addition, CSS only works when I put it in the style tag inside the <head> HTML. If I put CSS in a separate file, this will not work. (I correctly linked CSS to HTML)
PS link to the tutorial that I linked above, this will give you an idea.
UPDATE:
I made some changes to the HTML and now I have the text above the image. And the text no longer moves, but adds a space at the top. I tried margin but did not remove the space. I still cannot add anything below the image. HTML -
<body> <div class="wrapper bg" data-ibg-bg="pics/Q.jpg"> </div> <div class="main"> <h1> SOME TEXT </h1></div> </body>
CSS -
#main{ position: relative; }