Last active
May 14, 2021 14:38
-
-
Save pascalmaddin/5756515 to your computer and use it in GitHub Desktop.
An Image with parallax-effect and with some text, which is fading out while scrolling
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="banner"> | |
<div class="wrap-center"> | |
<div class="banner-centered" id="banner-text"> | |
<h2>Hello <strong>We Are Company-Name</strong>, Glad To See You. :-)</h2> | |
</div> | |
</div> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function scrollBanner() { | |
$(document).scroll(function(){ | |
var scrollPos = $(this).scrollTop(); | |
$('#banner-text').css({ | |
'top' : (scrollPos/3)+'px', | |
'opacity' : 1-(scrollPos/510) | |
}); | |
$('#banner').css({ | |
'background-position' : 'center ' + (-scrollPos/2)+'px' | |
}); | |
}); | |
} | |
scrollBanner(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#banner { | |
margin-bottom: 50px; | |
overflow: hidden; | |
width: 100%; | |
height: 500px; | |
position: relative; | |
clear: both; | |
background: transparent url(path/to/image/1.jpg) center center no-repeat fixed; | |
-webkit-background-size: cover; | |
-moz-background-size: cover; | |
-o-background-size: cover; | |
background-size: cover; | |
filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='path/to/image/1.jpg',sizingMethod='scale'); | |
-ms-filter: "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='path/to/image/1.jpg',sizingMethod='scale')"; | |
} | |
.wrap-center{ | |
margin: 0 auto; | |
position: relative; | |
max-width: 73.231em; | |
} | |
.banner-centered { | |
text-align: center; | |
position: absolute; | |
display: block; | |
max-width: 75.231em; | |
height: inherit; | |
overflow: hidden; | |
margin-top: 100px; | |
} | |
.banner-centered h2 { | |
font-size: 5.385em; | |
line-height: 1.5; | |
text-transform: uppercase; | |
letter-spacing: 2px; | |
color: #fafafa; | |
font-weight: 100; | |
display: block; | |
} |
Nice!
which links do i need to include to make it work?
and where do they go??
Great work though!
Nice work!
Good ! Nice work !
Awesome stuff! Thanks.
Thanks for this. Very nice little code. I've set up an example here so you can see what it does (I needed to show someone) http://codepen.io/AshboDev/pen/WGKXwg
Thanks
Nice work guy, thanks!
Awesome.
Thanks for this. Very nice little code. I've set up an example here so you can see what it does (I needed to show someone) http://codepen.io/AshboDev/pen/WGKXwg
I've seen your example and for me it shows a white background on an almost white text, It works but if someone wants to see it in action it'll be difficult without changing anything.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you so much