Skip to main content

Fix block to top of page

Comments

2 comments

  • Ariel H.

    Hi Rob,

    Thank you for contacting us.

    Unfortunately, this is not possible with current features.  This will require custom code to accomplish it.

    I have made a short screencast on this link - https://youtu.be/MjGNQJLyVoM

    Here is the JavaScript:


    <script>
     window.onscroll = function() {stickyBlock()};

    var div = document.querySelector(".breadcrumbs-area");
    var headerHeight = document.querySelector("#myheader").offsetHeight;
    var divOffsetTop = div.offsetTop;

    function stickyBlock() {
      if (window.pageYOffset > (divOffsetTop - headerHeight)) {
        div.classList.add("sticky");
      } else {
        div.classList.remove("sticky");
      }
    }
    </script>

    Here is the CSS:


    .breadcrumbs-area {
      position: relative;
    }

    .breadcrumbs-area.sticky {
      position: fixed;
      top: 80px; /* replace with the height of your header */
      width: 100%;
    }

    Please be advised that the custom code is offered as a one-time courtesy, and we cannot guarantee its functionality or provide ongoing maintenance or support for it.
    It is also important to note that every website is unique, and the CSS /JS may require some modifications. If necessary, please review the code and make any necessary adjustments to fit your website.

    Best regards,
    Ariel H.

     

    0
  • Rob Dawson

    Hi Ariel,

    Thanks for your detailed response. I tried to get it to work but was ultimately unsuccessful. I don't think there was any problem with your code as I tested all the variables and values, and everything was getting populated correctly - it just didn't fire when I scrolled the page.  For the short term I have added the breadcrumb to the existing main header and used a margin setting to cover it when on the home page.  Not perfect, but a workaround I can live with until I get time to revisit it.  I appreciate your effort - your response was exactly what I was looking for and hopefully can help others if they are looking for the same functionality.

    Regards,

    Rob

    0

Please sign in to leave a comment.