简体   繁体   中英

Getting webpage content using Bootstrap 3 positioned above animated background correctly

The overview: I'm using Bootstrap 3 as my CSS Framework, thus the content is organized using its container/grid system. The background animation consists of blue/green diagonal strips that basically zig zag with each other. The animated background sequence is using two images that are repeated vertically. Currently the animation background images are in their own container/divs. Essentially I'm trying to fit a number of containers with the content above the background container.

My goal is to have the animated background responsive to device size but also able to have content anchored to specific places on the page background/animation. Eventually I would like to have additional events triggered according to the mouse's y-axis position.

Originally I thought I could have the background in its own container then have the containers/div's that contained the content set to a higher z-index so it would be positioned above the background animation. As you can see from looking at the jsfiddle I can't get the contents containers to be positioned above the background animation. It gets pushed to the bottom of the page.

I'm wondering if I need to make the background in its own non bootstrap div while only the contents use bootstrap? I could use width: 100% and height: 100% but then I I'm not sure if I would be able to anchor/fix certain content to specific points in the page.

I'm open to any and all suggestions. Simply put I want to have the contents position correctly over the animated background while also allowing the page to be responsive to device size.

<body>        
    <div class="container">
        <div class="bluestrip">
            <img src="http://i59.tinypic.com/rt0txj.jpg" />
        </div>
        <div class="greenstrip">
            <img src="http://i57.tinypic.com/auv6fb.jpg" />
        </div>
        <div class="bluestrip extra">
            <img src="http://i59.tinypic.com/rt0txj.jpg" />
        </div>
        <div class="greenstrip">
            <img src="http://i57.tinypic.com/auv6fb.jpg" />
        </div>
        <div class="bluestrip extra">
            <img src="http://i59.tinypic.com/rt0txj.jpg" />
        </div>
        <div class="greenstrip">
            <img src="http://i57.tinypic.com/auv6fb.jpg" />
        </div>
    </div>
    <div class='container zindex'>
        <div class="row">
            <div class='col-md-2'>
                <img src="http://s26.postimg.org/8jazgghop/largest_iphone_3_of_3_14.gif">
            </div>
            <div class='col-md-2'>
                <img src="http://s26.postimg.org/c46uzom89/medium_iphone_2_of_3_14.gif">
            </div>
            <div class='col-md-2'>
                <img src="http://s26.postimg.org/c46uzom89/medium_iphone_2_of_3_14.gif">
            </div>
        </div>
    </div>
</body>

http://jsfiddle.net/bismarck611/jt2k4o6z/

I was able to solve the problem with a few code changes. Never figured out if it was possible to have two containers stacked over each other with different z-index's.

<body>        
    <div class="background-content">
        <div class="bluestrip">
            <img src="http://i59.tinypic.com/rt0txj.jpg" />
        </div>
        <div class="greenstrip">
            <img src="http://i57.tinypic.com/auv6fb.jpg" />
        </div>
        <div class="bluestrip extra">
            <img src="http://i59.tinypic.com/rt0txj.jpg" />
        </div>
        <div class="greenstrip">
            <img src="http://i57.tinypic.com/auv6fb.jpg" />
        </div>
        <div class="bluestrip extra">
            <img src="http://i59.tinypic.com/rt0txj.jpg" />
        </div>
        <div class="greenstrip">
            <img src="http://i57.tinypic.com/auv6fb.jpg" />
        </div>
    </div>
    <div class='container zindex'>
        <div class="row">
            <div class='col-md-2'>
                <img src="http://s26.postimg.org/8jazgghop/largest_iphone_3_of_3_14.gif">
            </div>
            <div class='col-md-2'>
                <img src="http://s26.postimg.org/c46uzom89/medium_iphone_2_of_3_14.gif">
            </div>
            <div class='col-md-2'>
                <img src="http://s26.postimg.org/c46uzom89/medium_iphone_2_of_3_14.gif">
            </div>
        </div>
    </div>
</body>

The div that is holding the img's I changed the css class to the following:

.background-content {
    position: absolute;
    z-index: -1;
    min-width: 100%;
    min-height: 100%;
}

This allowed for the images to resize themselves according to screen size and fit below the page contents. Now I'm still able to use the bootstrap framework over my css animated background.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM