Skip to main content

Create a sticky ad

Sticky ads can be created using Ad Commander Pro’s “Sticky” automatic insert. Sticky placements can be used to display any type of ad or group.

Creating a sticky ad

First, create the ad or group that you’d like to show in your insert.

Next, create an automatic insert and select the Sticky insert position.

Finally, customize your trigger, positioning, and auto-close settings.

Sticky ad placement

Fixing sticky ad display issues

Ad Commander’s Sticky ads use very minimal CSS to avoid creating conflicts with your existing site styles. The sticky ad container is inserted just before your site’s </body> tag. It is assigned position: fixed, positioned based on your chosen settings, and has a width and height set to auto. The ads inside the sticky container should dictate the size of your sticky ad. However, depending on the styling of your ad and your theme, your sticky container may require additional custom CSS.

Sticky ad overlaying elements or behind elements

Sticky ads are assigned a z-index of 1000 (as of Ad Commander Pro 1.2.1). There may be some cases where you’d like to customize this. The z-index CSS variable is assigned to body. You can overwrite it as needed:

body {
    --adcmdr-sticky-zindex: 2000;
}

Note that ‘adcmdr’ should be replaced with your custom prefix if one is in use.

Sticky ads also contain a unique ID, allowing you to target specific sticky ads if needed.

Additional CSS variables

The following CSS variables are assigned to the body element and can be customized as needed.

body {
	--adcmdr-sticky-zindex: 1000;
	--adcmdr-sticky-speed: var(--adcmdr-speed);
	--adcmdr-sticky-ease: var(--adcmdr-ease);
	--adcmdr-offset-top: 0px;
	--adcmdr-offset-right: 0px;
	--adcmdr-offset-bottom: 0px;
	--adcmdr-offset-left: 0px;

	--adcmdr-sticky-close-font-size: 1.5rem;
	--adcmdr-sticky-close-top: calc(
		-1 * (var(--adcmdr-gutter-width) + var(--adcmdr-sticky-close-font-size) / 2)
	);
	--adcmdr-sticky-close-right: calc(-1 * var(--adcmdr-gutter-width));
}

Note that ‘adcmdr’ should be replaced with your custom prefix if one is in use.