If you have structured your HTML as follows:
<div id="sky-container">
<div id="cloud-container">
...
</div>
</div>
<div id="text-container">
...
</div>
Congratulations, you are almost finished! All you need to do is position them correctly using absolute positioning. The text should already be appearing above the clouds. However, if your HTML looks like this:
<div id="cloud-container">
...
</div>
<div class="background">
<div class="background">
<div class="text">
...
</div>
<div class="text">
...
</div>
...
</div>
For instance, if you don't have a singular background, you can still insert the clouds between the background and the text. Simply separate the background and text in the HTML. You can utilize a z-index
to place the clouds between the text and the background:
.background{
z-index:0;
}
#cloud-container{
z-index:1;
}
.text{
z-index:2;
}
As the default z-index
is 0, if you anticipate the cloud container to be the final element on the page (and the one that is set to position:absolute
), you can streamline the CSS to:
.text{
z-index:1;
}
An element with a z-index must also have its position
property explicitly defined as either absolute
, relative
, or fixed
.