Tagged: sticky column
-
AuthorPosts
-
February 27, 2020 at 8:12 am #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!
February 28, 2020 at 9:51 pm #1188917Hey GeoffreyTMoore,
We are only seeing this, please post credentials so that we can see the page.
Best regards,
VictoriaFebruary 29, 2020 at 12:09 am #1188969This reply has been marked as private.March 1, 2020 at 5:54 pm #1189229Hi,
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.
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,
MikeMarch 6, 2020 at 3:13 am #1190714Thanks, 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!
March 6, 2020 at 1:06 pm #1190854Hi,
Thanks for the update. We’ll keep this thread open for you in case you should need any further help.
Best regards,
RikardMarch 6, 2020 at 1:49 pm #1190873Or 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=stickyMarch 7, 2020 at 12:50 pm #1191097 -
AuthorPosts
- You must be logged in to reply to this topic.