Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Hide position absolute element behind position relative element

Featured Replies

Hey

 

I'm stuck on this one so would be grateful for any help.

 

I have an anchor with a span in it. The anchor has position:relative on it and the span has position:absolute;top:0;left:0;

 

I want to hide the span behind the anchor. I've tried using z-index's but this isn't working. I'm guessing that only works if they are both positioned absolute.

 

I know I could use display:none but I don't want to because I'm animated the span as if its coming out from behind the anchor.

 

Thanks for any help

You could try positioning them both absolutely within a DIV and then using z-index to force the span behind the anchor.

 

Something like:

 

<div style="position:relative;">
<a style="position:absolute;z-index:1;top:0;"> link here </a>
<span style="position:absolute; z-index:0;top:0;"> </span>
</div>

 

Not sure if it's exactly what you mean!

 

Lyndsey.

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.