1. PROMO Upgrade to Pro Membership @ $99 / Lifetime & access all our 16+ premium Divi extensions: Divi Block, Carousel Toolkit, etc.LEARN MORE
Dismiss Notice
NEW Divi.Help Pro Carousel AI Toolkit - Magically turn your Divi design into carousel, simply by using our online toolkit. No plugins needed. Now it works with Divi 5 as well!Try our carousel AI toolkit
BEST Divi Block - A revolutionary drag & drop tool to easily mix & match 960+ premade blocks (Light & Dark) to kick start your Divi site design. Special module designs are included as well. Also newly added AI generator & color. Now it works with Divi 5 as well!
Learn More About Divi BlockFree Version ~ 340+ Free Blocks

Anchor links on not working on disabled sections

Discussion in 'Free Divi Community Forum' started by Janson Lietzke, May 21, 2024.

  1. Janson Lietzke

    Janson Lietzke New Member

    I am having issues getting anchor links to work on my mobile site. I am pretty certain it is because I have made multiple sections with the same anchor links. I have two sections for each of the companies' services, one disabled on desktop and tablet and one disabled on phone. Right now the links work on desktop but not mobile. How do I get the links to work on mobile as well? Thanks!
     
    1. PRO MEMBER PERKS Divi Ultimate Header Plugin - Add custom vertical navigation for your Divi site. Turns into slide in menu on mobile:Learn More
  2. Divi Booster

    Divi Booster Divi Expert

    Hey Janson,

    I've seen this type of thing before and yes, I'd imagine that having multiple sections with the same anchor links would be the problem - since CSS IDs are supposed to be unique on the page, the browser will typically only look at the first one (e.g. the desktop section) and ignore any subsequent ones.

    There are a few possible workarounds:

    If the two sections differ only in their row content, you could combine them into one section and enable / disable the rows on the different device widths, leaving the main section visible at all times with the ID set on it. That way you'd always be linking to the same section.

    If the two sections differ sufficiently, then instead of disabling the desktop section, you could style it to be, for example, 1px high. Disable the rows it contains on mobile and set the height / margin / padding on mobile such that it takes up very little vertical height. Ideally also set it to have the same background color as a neighboring section. That way it is still displayed in the page (and hence can be linked to using the anchor link) but doesn't have a noticeable visual impact. Again, just use this one section for the anchor linking.

    If you are just linking to the anchors from buttons / links from a small number of places (on the same site), you could give the mobile and desktop versions of the section different CSS IDs and then create mobile versions of these buttons / links which link to the mobile version of the section. Then hide / show the mobile / desktop versions of the buttons / links as appropriate. It's probably a bit of a messier solution compared to the ones above though.

    I think other than that you'd have to look at custom code to either switch the section IDs or link targets depending on the device width.