Reputation:
Good day, can I make my div as a Background?
or how can I set my div at the back of another Div.
Upvotes: 2
Views: 3251
Reputation: 668
the right way to do it is this 4 things:
z-index:-1
.background_div { background-color:red; width:100%; height:100%; position:fixed; z-index:-1; }
Upvotes: 4
Reputation: 6110
If you want to get really funky, you could go with the CSS element()-function (Only working in Firefox). As by the specification:
Starting in Gecko 2.0, you can use the element() CSS function to use an arbitrary HTML element as a background image for background and background-image
This simply means that you can use an actual div
(or any other HTML element) to be the background-image
or another element. I experimented with this feature before, gave some pretty interesting results.
(But it isn't that really useful...)
Upvotes: 1
Reputation: 3250
HTML
<div class="test"></div>
CSS
.test{width:100%;height:100%;background:red;display:block;position:absolute;}
Live Example http://jsfiddle.net/YC6wD/
Upvotes: 0
Reputation: 2805
I think you can use two div tags and give the position as absolute and then give background to one of the div like this :
<div class="abc">
</div>
<div class="xyz">
dgffsgf
</div>
and css like :
.abc{
position:absolute;
background-color:red;
height:100%;
width:100%;
}
.xyz{
position:absolute;
}
This will get your work done!!
Working Code :Div
Upvotes: 3