Skip to content

Instantly share code, notes, and snippets.

@smunchi
Created June 15, 2015 02:23
Show Gist options
  • Select an option

  • Save smunchi/5118cd674362feef8f0f to your computer and use it in GitHub Desktop.

Select an option

Save smunchi/5118cd674362feef8f0f to your computer and use it in GitHub Desktop.
Use of z index css property
Position an image behind the text
img {
position: absolute;
left: 0px;
top: 0px;
z-index: -1;
}
<h1>This is a heading</h1>
<img src="w3css.gif" width="100" height="140">
<p>Because the image has a z-index of -1, it will be placed behind the text.</p>
Another use of z index might be the one when you use position fixed for the header bar, then all text will be behind the header bar
#header {
background-color: #111111;
color: #FFFFFF;
height: 40px;
margin: 0;
position: fixed;
top: 0;
width: 100%;
z-index: 1000;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment