» » Fixed background and scrolling page effect with CSS

 

Fixed background and scrolling page effect with CSS

Author: bamboo06 on 13-08-2016, 01:54, views: 1452

171
How to create a just simply and none requiring javascript and CSS property of background-attachment can be realized fixed page backgrounds and scrolling effect. We see that there are many project sites use parallax effect, parallax is generated by the dynamic changes and the background image and js script, but today we only need CSS.


HTML
HTML structure is very simple, a background image is fixed placement class .cd-fixed-bg div element for a class of .cd-scrolling-bg div element portion for scrolling. We can place multiple .cd-fixed-bg and .cd-scrolling-bg group.
<main> 
    <div class="cd-fixed-bg cd-bg-1"> 
        <h1><!-- title goes here --></h1> 
    </div>  
  
    <div class="cd-scrolling-bg cd-color-2"> 
        <div class="cd-container"> 
            <p> 
                Lorem ipsum dolor sit amet, consectetur adipisicing elit. Dolore incidunt suscipit similique, dolor corrupti cumque qui consectetur autem laborum fuga quas ipsam doloribus sequi... 
            </p> 
        </div>  
    </div>  
    ...other divs... 
</main> 


CSS
How to achieve the background of fixed and scrolling effect? At first, I want to use jQuery, maybe I should make a div to a fixed location, and then change the background image when scrolling the page, but feel bad get. And simple we can do a few lines of CSS, set background background-size value to a fixed element of cover, background-attachment value is set to fixed, thus achieving a single page background fixed and scrolling effect. Consider the following code:
body, html, main { 
    /* important */ 
    height: 100%; 
} 
  
.cd-fixed-bg { 
    min-height: 100%; 
    background-size: cover; 
    background-attachment: fixed; 
    background-repeat: no-repeat; 
    background-position: center center; 
} 
  
.cd-fixed-bg.cd-bg-1 { 
  background-image: url("../img/cd-background-1.jpg"); 
} 
.cd-fixed-bg.cd-bg-2 { 
  background-image: url("../img/cd-background-2.jpg"); 
} 
.cd-fixed-bg.cd-bg-3 { 
  background-image: url("../img/cd-background-3.jpg"); 
} 
 
  
.cd-scrolling-bg { 
    min-height: 100%; 
} 

Category: CSS

Dear visitor, you are browsing our website as Guest.
We strongly recommend you to register and login to view hidden contents.
<
  • 0 Comments
  • 0 Articles
12 June 2017 07:18

hwerfg

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
<
  • 0 Comments
  • 0 Articles
8 November 2017 16:29

Custom essay writing service

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
very informative article. I love your site so much. custom essay writing service you have shared an informative post.

<
  • 0 Comments
  • 0 Articles
4 December 2017 14:38

JamesExpag

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
red viagra tablets
<a href="http://viagrajnmeo.com/#">viagra without a doctor</a>
come comprare viagra online paypal
viagra without prescription
over counter pill works like viagra

<
  • 0 Comments
  • 0 Articles
4 December 2017 16:10

Robertvar

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
viagra images pill
<a href="http://viagrajnmeo.com/#">viagra without a doctor</a>
buy viagra cialis levitra.php
viagra without a doctor’s prescription
cheap generic viagra and cialis

<
  • 0 Comments
  • 0 Articles
4 December 2017 19:51

Alana Tripp

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
With the help of java and CSS we are making any kind of useable program. I am programmer in paper writing service reviews company and makes the scroll bar it’s too much easy in java script.

<
  • 0 Comments
  • 0 Articles
11 December 2017 03:53

Evelynlon

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
payday advance
pay day loans
<a href="https://smajloans.com/">cash loans</a>
online payday loans

<
  • 0 Comments
  • 0 Articles
13 December 2017 04:17

Katrinaanisa

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
cash loans
payday loans no credit check
<a href="https://smajloans.com/">payday loan online</a>
payday loans

<
  • 0 Comments
  • 0 Articles
15 December 2017 15:15

Terriwop

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
payday loans
payday loans no credit check
<a href="https://smajloans.com/">payday loans no credit check</a>
payday loans online

payday loans online
payday loans online
<a href="https://smajloans.com/">payday loans</a>
payday loans

<
  • 0 Comments
  • 0 Articles
17 December 2017 15:30

VondaPanuh

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
get cash
regions loans
<a href="https://smajloans.com/">credit loan</a>
average loan interest rate

<
  • 0 Comments
  • 0 Articles
17 December 2017 19:17

Rosettabrada

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
payday loans online
payday loans
<a href="https://smajloans.com/">payday loans online</a>
payday loans

<
  • 0 Comments
  • 0 Articles
20 December 2017 12:51

Michaelflach

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
buy discount generic cialis
<a href="http://naqsehuki.com/#">buy cialis</a>
cialis sale nz
cheap cialis
buy cialis online uk no prescription

<
  • 0 Comments
  • 0 Articles
21 December 2017 00:56

Shannonnug

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
buy viagra cialis canada
<a href="http://naqsehuki.com/#">buy cialis</a>
buy cialis in mexico
cialis online
generic cialis sale

<
  • 0 Comments
  • 0 Articles
21 December 2017 01:32

Georgeappef

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
cialis buy online cheap
<a href="http://naqsehuki.com/#">cheap cialis</a>
cialis mail order pharmacy
buy cialis online
buy cialis lilly

<
  • 0 Comments
  • 0 Articles
22 December 2017 12:35

Edwardbat

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
buying cheapest generic cialis soft tab
<a href="http://naqsehuki.com/#">buy cialis online</a>
buy daily cialis
order cialis online
cialis for sale in usa

<
  • 0 Comments
  • 0 Articles
22 December 2017 13:06

MichaelPrara

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
cheap cialis australia
<a href="http://naqsehuki.com/#">cialis online</a>
cialis pills for men
buy cialis online
buy cialis online

<
  • 0 Comments
  • 0 Articles
22 December 2017 15:11

Beatrizlit

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
payday loans no credit check
payday loans online no credit check
<a href="http://paydaynock.com/">payday loans no credit</a>
payday loans online no credit check

<
  • 0 Comments
  • 0 Articles
23 December 2017 01:59

Williamhum

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
buy levitra 1.84 pr pill
<a href="http://levitradbws.com/#">levitra 20 mg</a>
discount levitra online
vardenafil 20mg
order levitra
<a href="http://vardenafilghns.com/#">levitra 20 mg</a>
buy levitra overnight shipping
vardenafil
order levitra from canada

<
  • 0 Comments
  • 0 Articles
23 December 2017 15:46

Brucehoace

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
buy levitra cialis viagra
<a href="http://levitradbws.com/#">levitra</a>
levitra for sale philippines
levitra 20 mg
levitra sale philippines
<a href="http://vardenafilghns.com/#">levitra 20 mg</a>
order levitra online no prescription
levitra
buy levitra generic

<
  • 0 Comments
  • 0 Articles
23 December 2017 15:51

ShannonNem

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
meds sale levitra
<a href="http://levitradbws.com/#">levitra</a>
levitra cheap
levitra
buy levitra overnight shipping
<a href="http://vardenafilghns.com/#">levitra</a>
cheap cialis and levitra
levitra
cheap levitra professional oo

<
  • 0 Comments
  • 0 Articles
24 December 2017 02:13

Thomasicefe

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
buy levitra no prescription canada
<a href="http://levitradbws.com/#">vardenafil 20mg</a>
buy online levitra in usa
levitra 20 mg
cheap levitra online
<a href="http://vardenafilghns.com/#">vardenafil</a>
buy cialis levitra and viagra
vardenafil 20mg
buy levitra canada online

<
  • 0 Comments
  • 0 Articles
24 December 2017 02:56

JustinAbada

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
cheap viagra and levitra
<a href="http://levitradbws.com/#">vardenafil 20mg</a>
order levitra online canada
vardenafil 20mg
levitra buy online no prescription
<a href="http://vardenafilghns.com/#">levitra 20 mg</a>
buy levitra united states
vardenafil 20mg
levitra buy cheap

<
  • 0 Comments
  • 0 Articles
24 December 2017 09:45

Randyfex

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
cheap cialis once day
<a href="hhttp://cialisyrudgj.com/#">generic cialis</a>
buying cialis online uk
buy generic cialis
buy cheap generic cialis online
<a href="http://cialisuitykh.com/#">cheap cialis</a>
buy cialis cheap
cialis prices
where to order cialis online

<
  • 0 Comments
  • 0 Articles
24 December 2017 10:29

Jerrysag

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
cialis sale online canada
<a href="hhttp://cialisyrudgj.com/#">cialis generic</a>
where to purchase cialis cheap
buy generic cialis online
cheap cialis online india
<a href="http://cialisuitykh.com/#">cheap cialis</a>
cialis on sale
cialis prices
where to buy cialis online in canada

<
  • 0 Comments
  • 0 Articles
25 December 2017 00:00

Lionelagelp

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
order cialis overnight delivery
<a href="hhttp://cialisyrudgj.com/#">cialis generic</a>
how to order cialis online no prescription
buy generic cialis
buy generic cialis generic cialis
<a href="http://cialisuitykh.com/#">cheap cialis</a>
buy discount cialis
cialis prices
order cialis overnight

<
  • 0 Comments
  • 0 Articles
25 December 2017 00:01

Robertnug

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
can buy cialis over counter usa
<a href="hhttp://cialisyrudgj.com/#">cialis generic</a>
where to buy real viagra cialis online
buy generic cialis
order cialis online no prescription
<a href="http://cialisuitykh.com/#">cialis prices</a>
cialis dapoxetine buy
cialis price
discount cialis professional

<
  • 0 Comments
  • 0 Articles
25 December 2017 12:36

Bruceprard

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
sildenafil 25 mg precio
<a href="http://viagratutrjdsd.com/#">buy viagra</a>
viagra sale manila
viagra online
can buy viagra pakistan
<a href="http://viagraeyefbdj.com/#">online viagra</a>
ordering viagra online
online viagra
buy viagra online in dublin

<
  • 0 Comments
  • 0 Articles
26 December 2017 14:42

AlbertMaisK

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
buy cialis mississauga
<a href="http://cialisietwdffjj.com/#">cialis cost</a>
buy generic cialis in usa
cialis best price
buy cialis brand online
<a href="http://cialisytigjtuj.com/#">cialis prices</a>
cialis discount price
cialis cheap
discount canadian cialis

<
  • 0 Comments
  • 0 Articles
27 December 2017 02:34

ThomastuS

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
can you buy generic cialis usa
<a href="http://cialisietwdffjj.com/#">cialis best price</a>
cheap generic cialis uk
cialis price
best place buy cialis online
<a href="http://cialisytigjtuj.com/#">cialis prices</a>
order cialis on internet
cialis prices
buy cialis using paypal

<
  • 0 Comments
  • 0 Articles
27 December 2017 14:13

TravisExord

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
buy cialis money order
<a href="http://cialisietwdffjj.com/#">cialis prices</a>
viagra cialis pills
cialis best price
buy cialis lilly
<a href="http://cialisytigjtuj.com/#">cialis prices</a>
cheap generic cialis no prescription
cialis prices
cialis wholesale india

<
  • 0 Comments
  • 0 Articles
28 December 2017 01:44

SarahCargy

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
online casino
casino games
<a href="http://bom777casino.com/">casino games</a>
online casino

Previous Next

Add comments

Name:*
E-Mail:
Comment:
Bold Italic Underline Strike | Align left Center Align right | Insert smilies Insert link URLInsert protected URL Select color | Add Hidden Text Insert Quote Convert selected text from selection to Cyrillic (Russian) alphabet Insert spoiler
Security Code: *