Fixed position and z-index

Yes, those fixed-positioned elements are annoying; please bear with me.

The two fixed-position divs on this page are marked up as:

<div class="fixed" id="green"></div>
<div class="fixed" id="orange"></div>

and styled thus:

.fixed { width: 50%; margin: 0 auto; height: 50px;
    position: fixed; }

#green  { top: 50px; background-color: #CEE14B; }
#orange { top: 110px; background-color: #FCAF3E; z-index: 1; }

Note that the lower, orange element has a z-index specified, whilst the first element doesn’t. The ul just below this text has a relative position. When the page is scrolled, and the orange div overlaps that list, all looks fine. When the green div overlaps it, however, the list items are shown in front of it.

Is this a bug, or expected behaviour? I’m really not sure. Comments, please!



Sat 28 Nov 2009 09:57


Danny said:

expected behavior…

Since the green DIV has no z-index priority… it is on the same plane as every other non z-indexed element on the page. The indexing now falls to where it’s placed in the code. Since it’s before the UL list… it has a lower indexing on that plane… If you place the green DIV after the UL list… you'll see that it now goes over the UL list… thus having a higher indexing on that plane…

Fri 22 Jan 2010 12:30


raf said:

Sounds plausible and works as you described, Danny. But how come the paragraph following the list, "Is this a bug…", does not behave the same way? Why does this behaviour only apply to the list?

Sun 24 Jan 2010 11:27

Five Minute Argument

Five Minute Argument said:

@raf: That paragraph is not positioned, so it’s in the normal flow. With no z-index (and, therefore, the deafult value 'auto'), the positioned green div will be rendered 'in front of' any normal-flow block.

z-index gets pretty complicated, especially when nesting blocks or applying a negative value to the property. I think a nice visual example covering the possible cases is called for.

Mon 2 May 2011 13:02


Thanks, you saved my time.

Wed 24 Aug 2011 03:21

Simon Brandon

Simon Brandon said:

You are an absolute star — I've been pulling my hair out trying to get a div to go above a fixed position div for ages, messing around with z-index without success. Just set the div in question to position:relative and it happily slides over the position:fixed div.

Thu 13 Oct 2011 13:44

Jonathan Gala

Jonathan Gala said:

Nice illustration, thanks.

Simon and Five Minute Argument: there is a nice tutorial on z-index (and some bugs in earlier IE implementations) here:

… that’s not my site, btw, but it’s a good overview, with nicely prepared examples. It helped my understanding of z-index a lot.

Wed 14 Dec 2011 01:21


Jim said:

Thanks for raising this issue along with an example — and thanks a lot Danny for answering it. Perfect!



Sat 13 Dec 2014 12:11

non prescription cialis online pharmacy

non prescription cialis online pharmacy said:

Hi there, I enjoy reading all of your post. I like to write a

little comment to support you.

Mon 15 Dec 2014 21:23

generic cialis canada

generic cialis canada said:

Your means of explaining all in this post is genuinely good, all be capable

of effortlessly understand it, Thanks a lot.

Fri 19 Dec 2014 01:46

north west pharmacy canada

north west pharmacy canada said:

WOW just what I was looking for. Came here by searching for canadian prescription drugs

without prescription

Sat 20 Dec 2014 09:41

canadian cialis pills

canadian cialis pills said:

Thanks for the auspicious writeup. It actually was a leisure account it.

Glance advanced to far delivered agreeable from you!

By the way, how can we keep in touch?

Sat 20 Dec 2014 09:51

cialis 20mg

cialis 20mg said:

excellent submit, very informative. I wonder why the opposite specialists of this sector do not realize this.

You must continue your writing. I am sure, you have a great readers' base already!

Wed 24 Dec 2014 16:24

cialis com

cialis com said:

Greetings! Very helpful advice within this post!

It is the little changes that will make the biggest changes.

Many thanks for sharing!

Tue 30 Dec 2014 01:43

canadian cialis

canadian cialis said:

Hello colleagues, its great paragraph concerning tutoringand entirely defined, keep it up all the time.

Tue 30 Dec 2014 06:03

goodrx coupons

goodrx coupons said:

Hi there, I found your site via Google even as searching for

a comparable topic, your web site came up, it appears good.

I've bookmarked it in my google bookmarks.

Hi there, just was aware of your weblog thru Google, and located

that it is truly informative. I’m going to be careful for brussels.

I will be grateful if you happen to continue this in future.

Numerous other folks can be benefited from

your writing. Cheers!

Tue 30 Dec 2014 06:46

canada pharmacy online viagra

canada pharmacy online viagra said:

I loved as much as you will receive carried out right here.

The sketch is attractive, your authored

material stylish. nonetheless, you command get got an nervousness over

that you wish be delivering the following. unwell unquestionably come more formerly again as exactly the same nearly a lot often inside case you shield this increase.

Thu 1 Jan 2015 10:25


northwestpharmacy said:

Hurrah, that’s what I was searching for, what a data! existing here at this webpage, thanks

admin of this web site.

Thu 8 Jan 2015 10:39

north west pharmacy canada

north west pharmacy canada said:

Hiya! Quick question that’s entirely off topic. Do you know how to make your site mobile

friendly? My blog looks weird when viewing from my iphone.

I’m trying to find a template or plugin that

might be able to fix this problem. If you have any recommendations, please share.

Thank you!

Mon 12 Jan 2015 20:49

online pharmacy cialis

online pharmacy cialis said:

Hey! I just wanted to ask if you ever have any problems with hackers?

My last blog (wordpress) was hacked and I ended up losing many months of hard work

due to no backup. Do you have any solutions to stop


Tue 13 Jan 2015 13:25


bvhitud said:


Wed 14 Jan 2015 07:13

cialis daily 5 mg price

cialis daily 5 mg price said:

Very nice article, totally what I needed.

Fri 16 Jan 2015 14:54

Pet medications cheap

Pet medications cheap said:

Useful information. Lucky me I discovered your website by accident,

and I am stunned why this coincidence didn’t took place earlier!

I bookmarked it.

Fri 16 Jan 2015 16:01

Cialis dreampharmaceuticals online

Cialis dreampharmaceuticals online said:

Hi! This post couldn’t be written any better! Reading through this post reminds me of my good old room mate!

He always kept chatting about this. I will forward this post to him.

Fairly certain he will have a good read. Thank you for sharing!

Sat 17 Jan 2015 11:23

Cialis paypal canada

Cialis paypal canada said:

I every time emailed this blog post page to all my contacts, because if like to

read it next my friends will too.

Sun 18 Jan 2015 09:47


hello said:

yzqnzwo <a href=" ">pjbuqyt</a> [url=]pjbuqyt[/url]

Sun 18 Jan 2015 16:22

Cialis online pharmacy uk

Cialis online pharmacy uk said:

Wow, wonderful blog structure! How lengthy have you ever been blogging for?

you made blogging glance easy. The full glance of your site is great,

let alone the content material!

Tue 20 Jan 2015 01:12

payday loans

payday loans said:

byhetfz payday loans >:]] payday loans ZFgZOV payday loans >:]] pay day loans 9582 payday loans 1121 pay day loans 4049

Wed 21 Jan 2015 01:21

walgreens drug store

walgreens drug store said:

Great article, exactly what I needed.

Wed 21 Jan 2015 12:22

how to buy cialis in canada

how to buy cialis in canada said:

Hi it’s me, I am also visiting this web site regularly, this

site is really pleasant and the visitors are truly sharing fastidious thoughts.

Thu 22 Jan 2015 10:08

online pharmacies canada

online pharmacies canada said:

The Commonly used pharmacy is very very affordable whether you are from whichever

parts of the community. The value is affordable

for everyone and anyone; you want to drive of buying it.

At the time verdict is created, look at the best retail store.

Subsequent to purchasing the drugs, you have ingested it.

Just take the drugs with simple standard water. canadian drug

Leave a comment