Jump to content

Making a div appear behind the rest of the page

Jeroen1322

Hi guys!

 

I want a <div> tag to be kind of a background so it doesn't scroll down and when you scroll the rest of the page go's above it.

 

Sorry for the bad explanation but hope you can help!

 

Thanks!

[CPU: AMD FX-6100 @3.3GHz ] [MoBo: Asrock 970 Extreme4] [GPU: Gigabyte 770 OC ] [RAM: 8GB] [sSD: 64gb for OS] [PSU: 550Watt Be Quiet!] [HDD: 1TB] [CPU cooler: Be Quiet! Shadow Rock Pro Sr1]  -Did i solve your question/problem? Please click 'Marked Solved'-

Link to comment
Share on other sites

Link to post
Share on other sites

I would do This like this:

 

Hope it helped ;)

 

Leo

 

//EDIT

Change to Position Fixed if you don't want it to scroll, didn't read correctly. But anyway, consider just to use Percentage values if you work with fixed position or do separate CSSs for Mobile. It's quiet a mess if you zoom ;)

 html{    min-height:100%;    position:relative} #div_ID{position:absolute;// or fixed if it should not scroll height:100%;width:100%;top:0;right:0; //Your Custom code z-index: -1000;}

Business Management Student @ University St. Gallen (Switzerland)

HomeServer: i7 4930k - GTX 1070ti - ASUS Rampage IV Gene - 32Gb Ram

Laptop: MacBook Pro Retina 15" 2018

Operating Systems (Virtualised using VMware): Windows Pro 10, Cent OS 7

Occupation: Software Engineer

Link to comment
Share on other sites

Link to post
Share on other sites

If you don't want it to scroll with the page and work like a background, it should be given the following styles:

position: fixed;top: 0;left:0;width:100%;height: 100%;z-index: -1000;

HTTP/2 203

Link to comment
Share on other sites

Link to post
Share on other sites

 

If you don't want it to scroll with the page and work like a background, it should be given the following styles:

position: fixed;top: 0;left:0;width:100%;height: 100%;z-index: -1000;

 

Why do you put width:100% on a block element? It should already use all the available space.

Link to comment
Share on other sites

Link to post
Share on other sites

Why do you put width:100% on a block element? It should already use all the available space.

Habit I guess. You don't need it.

HTTP/2 203

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×