Floating a Q2W3 Fixed Widget in Divi

Written by Dan Mossop

The Q2W3 Fixed Widget (Sticky Widget) plugin allows you to mark individual widgets as sticky, meaning that when you scroll up the page they will stay in position on the screen, rather than scrolling out of sight with the rest of the content. A good use for the plugin is to create "floating" widgets which hover above the page content, for instance to have social share buttons visible at all times.

Unfortunately, in some themes (including the Divi Theme), setting float:left on the sticky widget will not move it into position on the sidebar. This is because the theme is made up of a number of other left-floated elements. These elements block the widget, effectively keeping it in position.

To work around this, we can use a bit of JavaScript (jQuery, actually) to move the widget into a new position within page. By placing it before the other components, we'll prevent them from blocking the widget's floating. Here is the jQuery to move a widget with id "text-4" to the start of the Divi Theme page content:

jQuery("#et-main-area").prepend(jQuery("#text-4"));

This frees the widget, but doesn't fully achieve the floating effect we want. So we need to add some CSS to make it look right:

#text-4 { width:200px !important; z-index:100; position:fixed; }
#text-4_clone { width:1;height:1; }

The first line sets the widget width and fixes it above the other content. The second line is used to prevent a hidden object created by the plugin from breaking the page layout. Note that the id selector in the second row is made up of the widget id followed by "_clone".

Now the widget should float on the left of the page. We may still need to set the top margin in the Q2W3 Fixed Widget settings to make sure the widget is not covered up by the header bar.

Transform Your Divi Site with WP Magic CTAs

Enhance your Divi site by creating dynamic, AI-driven call-to-actions with WP Magic CTAs. This plugin allows you to effortlessly increase post engagement and conversions by integrating highly-targeted CTAs directly into your WordPress posts using shortcodes or Divi's dynamic content. Perfect for making your posts more interactive and driving user action.

About Dan Mossop

Dan is a Scottish-born web developer, now living in Brisbane with his wife and son. He has been sharing tips and helping users with Divi since 2014. He created Divi Booster, the first Divi plugin, and continues to develop it along with 20+ other Divi plugins. Dan has a PhD in Computer Science, a background in web security and likes a lot of stuff, 

2 Comments

  1. where do I need to put this code?

    Reply

Submit a Comment

Comments are manually moderated and approved at the time they are answered. A preview is shown while pending but may disappear if your are cookies cleared - don't worry though, the comment is still in the queue.

Your email address will not be published. Required fields are marked *.

We may earn a commission when you visit links on our website.

Latest Posts

Hide the Page Title in the Hello Elementor Theme

Hiding the page title in the Hello Elementor theme allows you to create a cleaner and more customized page layout, free from default headings that may not fit your design. This is particularly useful for landing pages or custom content layouts where the default page...

How to Hide a Divi Module When Scrolling Up or Down

In this quick tutorial, I’ll show you how to hide a Divi module when scrolling in a specific direction (up or down), so that the module only shows when you want it to. This is especially useful when using Divi’s Scroll Effects feature and you have a effect you want to...

Fade a Divi Image Module Edge into the Background

Want to create a stylish fade effect on your Divi image module—where one side fades smoothly into the background? With a bit of CSS, you can make any edge (or corner) of the image fade out: top, bottom, left, right, or even diagonally.Fade a Divi Image Module Edge...

Hide the Header and Footer in the Hello Elementor Theme

Removing the default header and footer from your Hello Elementor theme allows for a streamlined and distraction-free website design. This is especially useful when creating unique landing pages, full-width layouts, or custom headers and footers with a page builder. In...

Setting up the Divi Password Box Module

Setting up password protection on a page can help you control access to sensitive or private content in WordPress, allowing only authorized visitors to view certain sections. With the Divi Password Box module, you can replace the plain Divi password form with a fully...