Put div in the background

2

I need the div 01 not to interfere with the positioning of the other divs, like the div 03 for example, ie that the div 03 comes soon after the div 02, that the divs follow the normal flow of the page without needing the div 01 , that the div 01 is a background div that does not interfere with the position of the others, so it looks like this: (I did a gambiarra to show this and if it was to use the page it would be all structured)

It'sasifthediv01didnotevenexistfortheotherdivs,asifitwereabackgroundimageplacedinthe'body'attribute!

How do I do this?

--------------- Resolved ----------------

I solved it like this:

The div 02 was inside the div 01, I placed the div 02 out and left the div 01 separate from the div 02:

Before:

<header>
    <div id="topo">
    </div>
</header>

Then:

<div id="fundo">
</div>
<header>
</header>

I added these attributes in the div # background:

position:absolute;
z-index:-1;

How it was:

And it worked, thank you all!

    
asked by anonymous 13.05.2015 / 20:05

3 answers

4

The ideal would be to give an answer based on your code, however as you did not post (it's the hint for correction), I'll tell you some solutions.

You can have multiple types of position in CSS .

Static

It follows the normal flow of <div> , that is, it works with blocks.

Relative

Accepts properties top , bottom , left and right for placement.

Absolute

Works with <div> and overlays plans. That is, do not ignore physics! It maintains the law that two bodies can not occupy even space and therefore, one overlaps the other.

Fixed

Basically the same thing as absolute , but the element stays fixed all the time on the screen. An example is those% dumpers that overlap all elements and stay fixed even though you use scroll.

Now another topic!

To work with the property in the overlay, we use the property popups that goes from 0 to X and defines which element will be over. Example:

HTML

<div id='primeiraDiv'> ... </div>
<div id='segundaDiv'> ... </div>
<div id='terceiraDiv'> ... </div>

CSS

#primeiraDiv{
z-index: 0;
}

#segundaDiv{
z-index: 1;
}

#terceiraDiv{
z-index: 2;
}
    
13.05.2015 / 20:23
3

I solved it like this:

The div 02 was inside the div 01, I placed the div 02 out and left the div 01 separate from the div 02:

Before:

<header>
    <div id="topo">
    </div>
</header>

Then:

<div id="fundo">
</div>
<header>
</header>

I added these attributes in the div # background:

position:absolute;
z-index:-1;

And it worked, thank you all!

    
13.05.2015 / 20:47
2

Ever try to tinker with the z-index of the divs? No css

#div1{
  z-index:20;
}
#div2{
  z-index:30;
}

This positions one over the other. Larger number positions div over

    
13.05.2015 / 20:21