# Keep the Last Sidebar Widget in View

> Makes the last widget in the sidebar stick to the top of the screen while the visitor scrolls long posts, a good spot for a newsletter form or ad.

- Type: CSS
- Runs: Site-wide header
- Category: [Widgets](https://wpide.com/library/category/widgets/)
- Tags: widgets, sticky, sidebar
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/sticky-last-sidebar-widget/

## Code

```css
@media (min-width: 1024px) {
    #secondary .widget:last-child,
    .widget-area .widget:last-child,
    .sidebar .widget:last-child {
        position: sticky;
        top: 2rem;
    }

    .admin-bar #secondary .widget:last-child,
    .admin-bar .widget-area .widget:last-child,
    .admin-bar .sidebar .widget:last-child {
        top: calc(2rem + 32px);
    }
}
```

## Notes

Only applies on screens wider than 1024 pixels. Adjust the selectors if your theme uses different sidebar classes.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Keep the Last Sidebar Widget in View" in its snippet library and add it in one click; or create a new CSS snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
