最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

Can wordpress post and sidebar remain visible after scroll?

matteradmin9PV0评论

My problem is that I have a long sidebar and most posts are somewhat short so when the user scrolls down after the end of the post they only see blank space on the left and just the sidebar on the right.

The sidebar should ideally scroll then fix when it gets to the bottom, then scroll up when the user scrolls up, then fix itself at the top until the scroll direction changes again. This is what happens inside the wordpress admin area for example.

This is used perfectly in the twentyfifteen theme.

I searched a lot but could not find a solution. I tried a plugin like "Sticky menu (or anything) on scroll" but it didn't work like twentyfifteen. I am using MagZen theme.

Any help appreciated.

My problem is that I have a long sidebar and most posts are somewhat short so when the user scrolls down after the end of the post they only see blank space on the left and just the sidebar on the right.

The sidebar should ideally scroll then fix when it gets to the bottom, then scroll up when the user scrolls up, then fix itself at the top until the scroll direction changes again. This is what happens inside the wordpress admin area for example.

This is used perfectly in the twentyfifteen theme.

I searched a lot but could not find a solution. I tried a plugin like "Sticky menu (or anything) on scroll" but it didn't work like twentyfifteen. I am using MagZen theme.

Any help appreciated.

Share Improve this question asked Feb 3, 2018 at 18:24 LazarosLazaros 113 bronze badges 0
Add a comment  | 

1 Answer 1

Reset to default 0

Sounds like a fixed position and 100% height are what you're after:

position: fixed; height: 100%;

The TwentyFifteen theme uses the following code in style.css:

@media screen and (min-width: 59.6875em) {
    body:before {
        display: block;
        height: 100%;
        min-height: 100%;
        position: fixed;
        top: 0;
        left: 0;
        width: 29.4118%;
    }

    .sidebar {
        float: left;
        margin-right: -100%;
        max-width: 413px;
        position: relative;
        width: 29.4118%;
    }

    .site-content {
        display: block;
        float: left;
        margin-left: 29.4118%;
        width: 70.5882%;
    }

Alternative: I've been using the 2015 theme and trying to get the left, persistent navigation sidebar to scroll independently of the content, instead of the default behavior.

From a user experience perspective, the user is scrolling the content, not the menu. When both sections scroll simultaneously, the user is encountering a lot more information, when they probably just want to see more of the main body.

If you interested in this alternative, see this SE thread.

Post a comment

comment list (0)

  1. No comments so far