Lay Theme Forum

    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Users
    • Search

    Text Element Sticky: stick to top on scroll

    General Discussion
    3
    9
    1036
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • yoontaemin
      yoontaemin last edited by

      Hi!

      Is it possible to assign a sticky function to a text element?

      On scroll, the text element should stick to the top when it hits the top.

      Cheers!

      taemin

      1 Reply Last reply Reply Quote 0
      • mariusjopen
        mariusjopen Global Moderator last edited by

        Hi Taemin,

        this is possible but not a default function from Laytheme.

        You need to do that with a little jQuery.

        http://bfy.tw/5nDR

        :-)

        Are you familiar with simple Javascript?

        Many wishes!

        Marius

        www.mariusjopen.world

        1 Reply Last reply Reply Quote 0
        • mariusjopen
          mariusjopen Global Moderator last edited by

          Ok, I am not that mean:

          jQuery(document).ready(function($) {
          
              function sticky()
              {
                  var window_top=$(window).scrollTop();
                  var top_position=$('body').offset().top;
                  var element_to_stick=$('#header');
                  
                  if (window_top > top_position) {
                      element_to_stick.addClass('sticky');
                  } else {
                      element_to_stick.removeClass('sticky');
                  }
              }
              $(window).scroll(sticky);
              sticky();
              
          });
          
          #header.sticky
          {
              position: fixed;
          }
          

          Have also a look here:
          http://laytheme.com/documentation.html#custom-javascript

          Many wishes!

          Marius

          www.mariusjopen.world

          1 Reply Last reply Reply Quote 1
          • C
            ccastells last edited by

            Hi!

            I have tried this but not succeeded:

            http://andrei-lascu.com/info

            I would like to have the Contact text block and the image stick to their original position and have only the middle grid scroll up.

            I have also tried with a simple position:fixed, and did not work.

            Can you please help me out?

            Thanks!
            Carlota

            1 Reply Last reply Reply Quote 0
            • mariusjopen
              mariusjopen Global Moderator last edited by

              Dear @ccastells
              you can add a CUSTOM CLASS to the element and give it a position: fixed.

              All the best!

              Marius

              www.mariusjopen.world

              C 1 Reply Last reply Reply Quote 0
              • C
                ccastells @mariusjopen last edited by

                @mariusjopen said in Text Element Sticky: stick to top on scroll:

                position: fixed

                Hi Marius,

                unfortunately with the position:fixed it also does not work.
                https://andrei-lascu.com/info-2

                Any idea on how can I fix this?

                Thanks,
                Carlota

                1 Reply Last reply Reply Quote 0
                • mariusjopen
                  mariusjopen Global Moderator last edited by

                  Dear @ccastells
                  if I look at your page I do not completely understand which part should move and which part should stay fixed on the page.

                  Best!

                  Marius

                  www.mariusjopen.world

                  C 1 Reply Last reply Reply Quote 0
                  • C
                    ccastells @mariusjopen last edited by

                    @mariusjopen

                    Hi Marius,

                    I would like the column in the middle to scroll, and have the left and right fixed.
                    https://andrei-lascu.com/info/

                    I tried the position:fixed in this other link to show that this does not work either:
                    https://andrei-lascu.com/info-2

                    Thanks,
                    Carlota

                    1 Reply Last reply Reply Quote 0
                    • mariusjopen
                      mariusjopen Global Moderator last edited by

                      Dear @ccastells

                      here a very rough sketch. Hope it brings you in the right direction :-)

                      .no-parallax.no-offset.col.push-0.span-2.align-top {
                          position: fixed;
                      }
                      
                      .no-parallax.has-offset.col.push-0.span-2.align-top {
                          position: fixed;
                          right: 20px;
                      }
                      
                      .has-parallax.no-offset.col.push-0.span-3.align-bottom {
                          padding-left: 30%;
                      }
                      
                      

                      Best!

                      Marius

                      www.mariusjopen.world

                      1 Reply Last reply Reply Quote 0
                      • First post
                        Last post

                      Try this to fix issues before you post:

                      Use the Search Feature. Maybe there is already a solution to your issue.

                      1. Update Lay Theme and all Lay Theme Addons
                      2. Disable all Plugins
                      3. Go to Lay Options → Custom CSS & HTML, click "Turn Off All Custom Code ", click "Save Changes"
                      4. Now see if your problem solved itself
                      5. Go here, see if your problem is listed here:
                      Troubleshooting

                      When you post:
                      1. Post a link to where the problem is
                      2. If the problem is difficult to explain, post screenshots / link to a video to explain it

                      Thanks!

                      Online Users

                      C
                      L

                      Recent Topics

                      • C

                        centred Carousel fixed width and proportions

                      • L

                        position Project titles outside the images on the side

                      • slow navigation WP admin control panel

                      • P

                        News element date and title order

                      laytheme.com