Tagged: 

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #1188338

    Hi there, I’d like to have my super long column scroll (right column) while I want the info in the next column to remain visible/static while the right gallery images are being viewed/scrolled. Can you help me create the CSS for that?

    Thanks!

    #1188917

    Hey GeoffreyTMoore,

    We are only seeing this, please post credentials so that we can see the page.

    Best regards,
    Victoria

    #1188969
    This reply has been marked as private.
    #1189229

    Hi,
    Thank you for the login, in order to make the left column sticky and retain it’s width and position and a fluid feel I recommend using jQuery. So the first step is to add a custom ID to your left column so we are only targeting this one, in the future if to create another page like this with the sticky column on the left and the distance from the top of 330px, you can use the same ID to also target it.
    2020-03-01-101050
    then we will add this code to the end of your functions.php file in Appearance > Editor:

    function sticky_column(){
      ?>
      <script>
    (function ($) {
        $(window).scroll(function (e) {
          var $sticky = $('#sticky-column');
          var width = $(window).width()
          var position = ($sticky.css('position') == 'fixed');
          if ($(this).scrollTop() > 100 && width >= 767 && !position) {
            $sticky.css({ 'position': 'fixed', 'top': '330px', 'width': $sticky.innerWidth() });
            $sticky.next().css('float', 'right');
            $sticky.addClass('fixed_element_style');
          }
          if ($(this).scrollTop() < 100 && position) {
            $sticky.css({ 'position': 'static', 'top': '0px', 'width': '' });
            $sticky.next().css('float', 'left');
            $sticky.removeClass('fixed_element_style');
          }
        });
    })(jQuery);
    </script>
    <?php
    }
    add_action('wp_footer', 'sticky_column');

    Then in your theme settings this option needs to be unchecked: Enfold Theme Options > Performance > Load jQuery in your footer
    Now you will see the column is sticky, you may need to clear your browser cache.
    The only issue is that you are not using a Child Theme so on your next update this customization will be lost. Please consider reading about child themes and using one.

    Best regards,
    Mike

    #1190714

    Thanks, I added a child theme and updated the theme files today. I will work on setting up the jQuery as you described. I appreciate your help. I’ll respond again after testing to see if I need further assistance. Thank you!

    #1190854

    Hi,

    Thanks for the update. We’ll keep this thread open for you in case you should need any further help.

    Best regards,
    Rikard

    #1190873

    Or you do it with flex-box modell – and only css –
    you can see it here with content and sticky sidebar: https://webers-testseite.de/sticky-sidebar/
    and the code you need to set in your quick css.
    and here is a page with colums: https://webers-testseite.de/sticky-elements/
    The thing to have in mind is that the direct partent container gets display: flex – and the sticky child is set to position: sticky
    Important on that to know for Enfold: overflow settings as described in the first link
    It is a nice thing because it get out of sticky when the sticky element comes to the end of the parent container.

    Great advantage : no scroll calcalation with performance requirements.
    But i guess : IE11 does not support: https://caniuse.com/#search=sticky

    #1191097

    Hi,

    Thanks for sharing and for helping out @guenni007 :-)

    Best regards,
    Rikard

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.