Jump to content

Set div at top of page no matter where you are on the page


aeroswat

Recommended Posts

So I have an update function that does something and then once it's done it should make a div visible then fade out. It does this well. Now I need to know how to set it so this div is always positioned at the top of the page no matter where I am scrolled to. Certain coordinates if you will.

 

Here's the page

____________

|                    x|

|                      |

|                      |

|                      |

|                      |

|___________ |

 

I always want it where that x is

 

Link to comment
Share on other sites

You will want to use CSS and more specifically a fixed position

.element
{
      position:fixed;
      top:0;
      left:95%;/*change this depending on how wide your element is*/
}

 

That should make it permanently positioned if I'm right :D

 

oh shit lol. Thanks. Didn't know I could do this with css. Btw since this goes off of the browser window using a % in the left will work right? It doesn't have to be in an outer relative div correct?

Link to comment
Share on other sites

Lol I wasn't sure what you were asking so I thought I'd just clarify what I meant a bit lol. It doesn't need to be in any extra div or element just apply those 3 lines of CSS and it should be fixed to the top corner.

 

May want to add a z-index to it though if you have loads of elements so it stays on top all the time.

Link to comment
Share on other sites

Lol I wasn't sure what you were asking so I thought I'd just clarify what I meant a bit lol. It doesn't need to be in any extra div or element just apply those 3 lines of CSS and it should be fixed to the top corner.

 

May want to add a z-index to it though if you have loads of elements so it stays on top all the time.

 

Ya i usually do a z-index for this of like some crazy number 200 or something just so i'm sure it's on top lol.

 

Btw it works thank you.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.