Select Page

Z-Index Not Working Position Absolute

Today I learned about the importance of the natural stacking order. I spent probably an hour scratching my head trying to figure out why my element with the z-index of 500 wasn’t appearing on top of another element with a z-index of -500. At first I thought it might have something to do with my CSS position attribute not playing nicely with z-index, but it had everything to do with the order in which elements appeared in my HTML.

As you can see in the example above, let’s assume the light grey rectangle is a <div> with the class of container or some encapsulating element containing three smaller elements on the same row. So, without any CSS positioning applied (relative, absolute, fixed, etc) these elements would naturally sit in this order from left to right.

For whatever reason, my z-index values weren’t being recognized. Z-index 500 elements were being tucked behind z-index -500 elements. I think the issue was, returning to the illustration above, I was offsetting element #3 by so many pixels such that it would overlap (ON TOP OF) the element number 2. But the natural stacking order of the HTML actually put element #2 on top of #3. And with my z-indexes, that wasn’t the result I was expecting.

So after a bit of research and trial and error, I actually changed the order of the elements and that was the trick that got me the result I was looking for.

Hope this helps somebody in the future.

Check out more articles

How to Generate a Ranger Config File

ranger --copy-config=all This will copy all the default config files from /usr/local/lib so you can make edits without messing anything up. Huge shout out to https://dquinton.github.io/debian-install/config/ranger.html for explaining this and so much more. Took me a...

First Open Source Contribution

Surprise! I genuinely did not plan on making my first ever open source contribution today. In fact, I didn't plan on a lot of things happening this week at all. I recently got an awesome opportunity to work on a site that is being hosted on a platform called Pantheon,...

How to Exclude Specific Posts and Pages from WP_QUERY

For the sake of having something to work with, let's suppose we've got the following query:In this query, inside the $args array, there's a special parameter that allows you to exclude specific posts and pages from the query. This parameter is called post__not_in and...

Configure SSH For Password-less Connections

Preamble I'm slightly embarrassed to admit this, but it was a long time before I figured out how amazing this little file is and how exactly to put it to good use. The file I'm talking about is the SSH config file. By default, when you first connect to a server via...

WordPress Site Stuck in Maintenance Mode

Plugin Error Code 500 During Update While I was updating a WordPress plugin locally, something happened on my local server to trigger a 500 error code as the plugin was updating. On the frontend, I refreshed the page and was greeted with "Briefly Unavailable for...

Creating a WordPress Plugin Downloader

How it Started I was recently tasked with the challenge of creating a WordPress theme generator. The idea being, instead of writing your style.css file from scratch, you'd be able to just answer a few simple questions about how you'd like your theme set up, and those...

Fix Audio on XFCE Chromebook

The Problem After moving from GalliumOS to Xubuntu, I noticed that playing YouTube videos on both Firefox and Chromium would result in decent playback for a few minutes, but suddenly the audio would turn into a solid beeping tone while the YouTube video displayed the...

Adjust Trackpad Sensitivity XFCE

xinput set-prop "Elan Touchpad" "Synaptics Finger" 1 1 1 What are the values 1 1 1? This sets the sensitivity as close to the original ChromeOS as possible. Larger numbers will decrease sensitivity of various aspects. I never looked into which individual value...

Fireworks (Short Film)

https://vimeo.com/395077249 About the film Year: 2020 Director/DP: Tim Searfoss Writers: Matt Jones, Tim Searfoss Sound Mix: Matt Jones

Hosting Multiple Sites Using LocalWP

I've done a write-up on hosting local WordPress sites before, but I definitely prefer this method over the previous one. If you've never tried hosting multiple sites using LocalWP, then I'd encourage you to check it out. I've had really bad issues with it in the past,...