Turning jumbotron into parallax header

I am using the jumbotron feature of Bootstrap 3 in my WordPress site. I use it to create a big header for my home page. I would like the text in there to parallax the background image.

The only examples I can find aren’t coded to work in WordPress. The JavaScript code I’m using so far is

Read More
var jumboHeight = $('.jumbotron').outerHeight();
function parallax(){
var scrolled = $(window).scrollTop();
$('.bg').css('height', (jumboHeight-scrolled) + 'px');
}

$(window).scroll(function(e){
parallax();
}); 

with this HTML:

<div class="container-fluid jumbotron"> 

<class = "bg"></div>
<header>    
        <nav class="navbar navbar-custom row" role="navigation">   
            <!-- Brand and toggle get grouped for better mobile display --> 
                <div class="navbar-header"> 

                <div class="navbar-brand">
                    <?php if (get_theme_mod(FT_scope::tool()->optionsName . '_logo', '') != '') { ?>
                        <a class="mylogo" rel="home" href="<?php bloginfo('siteurl');?>/" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>"><img relWidth="<?php echo intval(get_theme_mod(FT_scope::tool()->optionsName . '_maxWidth', 0)); ?>"  relHeight="<?php echo intval(get_theme_mod(FT_scope::tool()->optionsName . '_maxHeight', 0)); ?>" id="ft_logo" src="<?php echo get_theme_mod(FT_scope::tool()->optionsName . '_logo', ''); ?>" alt="" /></a>
                    <?php } else { ?>
                        <h1 class="site-title logo"><a id="blogname" rel="home" href="<?php bloginfo('siteurl');?>/" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>"><?php bloginfo( 'name' ); ?></a></h1>
                    <?php } ?>
                    </div>      
                </div> 

<!-- ... -->

The best I’ve got it is an image behind the jumbotron that does nothing.

Related posts

Leave a Reply