Jump to content

Recommended Posts

 

Here is the page in question:

https://www.courtsideindiana.com/season-preview/19-20/sectional1920/?sectional=8

 

I don't have any -- overflow: hidden; -- issues, at least not from what I see when I inspect the element.  I do my work in Safari, but I test a lot in Developer mode as well as a separate Chrome browser.  

 

CSS

div.navigation {

  position: -webkit-sticky;
  position: sticky;
  top: 0px;
  background-color: red;
  padding: 10px;
  font-size: 20px;
}

PHP/HTML

echo '<div class="navigation">Hello</div>';

 

Edited by Jim R
Link to comment
https://forums.phpfreaks.com/topic/309162-sticky-div-not-sticking/
Share on other sites

28 minutes ago, Barand said:

Does


position: fixed;

work?

Not as intended, and I had tried that earlier.  Sticky is supposed to keep the DIV relative until the "Top" is reached, then stick there.  Maybe it's a theme issue too that I'm using for WordPress, as it hides behind the main navigation until that is off screen.  I need it visible the whole time.  

I thought I was doing well to find the "main" issue that keeps "sticky" from working (overflow: hidden;), but I don't have that issue.  

 

  • 1 month later...

I know this is old, but for people coming and read this - position sticky works depending where the element is in the page hyrachy. To stick a div to the body coordinates  That div MUST exist in the body and not in another div.

so

<body>

<div class="navigation">Hello</div>

 

will work, but

<body>

<header>

<div class="navigation">Hello</div>

will not.

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.