Skip to content
  • Recent
  • Tags
  • Popular
  • Users
  • Search
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse

Lay Theme Forum

  1. Home
  2. General Discussion
  3. Text Element Sticky: stick to top on scroll

Text Element Sticky: stick to top on scroll

Scheduled Pinned Locked Moved General Discussion
9 Posts 3 Posters 1.4k Views
  • 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.
  • yoontaeminY Offline
    yoontaeminY Offline
    yoontaemin
    wrote on last edited by
    #1

    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
    0
    • mariusjopenM Offline
      mariusjopenM Offline
      mariusjopen
      Global Moderator
      wrote on last edited by
      #2

      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
      0
      • mariusjopenM Offline
        mariusjopenM Offline
        mariusjopen
        Global Moderator
        wrote on last edited by
        #3

        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
        1
        • C Offline
          C Offline
          ccastells
          wrote on last edited by
          #4

          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
          0
          • mariusjopenM Offline
            mariusjopenM Offline
            mariusjopen
            Global Moderator
            wrote on last edited by
            #5

            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
            0
            • mariusjopenM mariusjopen

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

              All the best!

              Marius

              C Offline
              C Offline
              ccastells
              wrote on last edited by
              #6

              @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
              0
              • mariusjopenM Offline
                mariusjopenM Offline
                mariusjopen
                Global Moderator
                wrote on last edited by
                #7

                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
                0
                • mariusjopenM mariusjopen

                  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

                  C Offline
                  C Offline
                  ccastells
                  wrote on last edited by
                  #8

                  @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
                  0
                  • mariusjopenM Offline
                    mariusjopenM Offline
                    mariusjopen
                    Global Moderator
                    wrote on last edited by
                    #9

                    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
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    I also code custom websites or custom Lay features.
                    šŸ’æ Email me here: šŸ’æ
                    info@laytheme.com

                    Before you post:
                    1. When using a WordPress Cache plugin, disable it or clear your cache.
                    2. Update Lay Theme and all Lay Theme Addons
                    3. Disable all Plugins
                    4. Go to Lay Options → Custom CSS & HTML, click "Turn Off All Custom Code", click "Save Changes"

                    This often solves issues you might run into

                    When you post:
                    1. Post a link to where the problem is
                    2. Does the problem happen on Chrome, Firefox, Safari or iPhone or Android?
                    3. If the problem is difficult to explain, post screenshots / link to a video to explain it
                    Online Users
                    Forgot your key, lost your files, need a previous Lay Theme or Addon version? Go to www.laykeymanager.com
                    laytheme.com
                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Search