Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1139965
    yhshin1020
    Participant

    Hey,

    I am using a custom Js to make the color of the background fade in and out as the user scrolls down the section.

    I’ve included these codes in my css:

    .supporthead{
        height: 100vh;
        padding-left: 7%;
        padding-right: 7%;
      	display: flex;
      	align-items: center;
      	justify-content: center;
        background-color: #FF006B !important;
    }
    
    .supporthead .scrolled { background: black !important; }

    This is in my JS:

    jQuery(function($) {
        $('.page-id-1234 input[name="_wpcf7_checkbox_free_text_id:nation"]').attr('placeholder','Please Specify');
        $('.page-id-1234 input[name="_wpcf7_checkbox_free_text_id:lang"]').attr('placeholder','Please Specify');
       $(window).scroll(function () {
            if($(document).scrollTop()>200){
              $('.supporthead').addClass('scrolled');
            }
            else {
              $('.supporthead').removeClass('scrolled');
            }
          });
    });

    I’ve tried this and it doesnt seem to work.

    Am i doing something wrong here?

    Thanks

    #1139967
    yhshin1020
    Participant
    This reply has been marked as private.
    #1140242
    Rad
    Moderator

    Hi there,

    Please change your CSS to this,

      .supporthead{
        height: 100vh;
        padding-left: 7%;
        padding-right: 7%;
      	display: flex;
      	align-items: center;
      	justify-content: center;
        background-color: #FF006B !important;
    transition: all 2s;
    }
    
    .supporthead.scrolled { background: black !important; }

    That should do it 🙂

    Cheers!

    #1140411
    yhshin1020
    Participant
    This reply has been marked as private.
    #1140498
    Thai
    Moderator

    You’re most welcome 🙂

  • <script> jQuery(function($){ $("#no-reply-1139965 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>