CSS sticky header onscrollSet cellpadding and cellspacing in CSS?Convert HTML + CSS to PDF with PHP?How do I give text or an image a transparent background using CSS?Is there a CSS parent selector?When to use margin vs padding in CSSChange an HTML5 input's placeholder color with CSSHow can I transition height: 0; to height: auto; using CSS?How do CSS triangles work?How do I vertically center text with CSS?Is it possible to apply CSS to half of a character?

Validation and verification of mathematical models

How can I refer to something in a book?

Why do private jets such as Gulfstream fly higher than other civilian jets?

Onenote - Reducing Storage Footprint on PC

Can external light meter replace the need for push/pull?

Is DC heating faster than AC heating?

How does the oscilloscope trigger really work?

Is it double speak?

Does this smartphone photo show Mars just below the Sun?

Will a paper be retracted if a flaw in released software code invalidates its central idea?

Repeated! Factorials!

Secure my password from unsafe servers

Is there a difference between 「目を覚ます」 and 「目覚める」

Unexpected route on a flight from USA to Europe

I was contacted by a private bank overseas to get my inheritance

Does a 4 bladed prop have almost twice the thrust of a 2 bladed prop?

Why does putting a dot after the URL remove login information?

Does this put me at risk for identity theft?

What is a Casino Word™?

Cobb-Douglas production function with expenditures rather than units

Pronouns when writing from the point of view of a robot

What is an air conditioner compressor hard start kit and how does it work?

How can glass marbles naturally occur in a desert?

Why should I "believe in" weak solutions to PDEs?



CSS sticky header onscroll


Set cellpadding and cellspacing in CSS?Convert HTML + CSS to PDF with PHP?How do I give text or an image a transparent background using CSS?Is there a CSS parent selector?When to use margin vs padding in CSSChange an HTML5 input's placeholder color with CSSHow can I transition height: 0; to height: auto; using CSS?How do CSS triangles work?How do I vertically center text with CSS?Is it possible to apply CSS to half of a character?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















I'm working with a Drupal 8.x template and I need to modify a sticky header that it get activated onscroll.



The header is transparent when the page load and ones the user scroll down it has a white background and it get stuck at the top of the page (just as a sticky header normally works...)



What I want to do it's to modify the code so it won't start transparent. I need it to have the white background from the start, as soon as the page loads and of course with the sticky function.



These are the two codes i found that make the sticky header work. Hope someone can help me!



CSS



.onscroll.transparent-header-active .header-container.js-transparent-header .sticky-wrapper 
height: 0 !important;

.onscroll .header.js-fixed
position: fixed;
z-index: 499;
top: 0;
width: 100%;
-webkit-box-shadow: 0 2px 14px rgba(100, 100, 100, 0.1), 0 2px 2px rgba(100, 100, 100, 0.1);
box-shadow: 0 2px 14px rgba(100, 100, 100, 0.1), 0 2px 2px rgba(100, 100, 100, 0.1);

.onscroll .header.js-fixed.region--white-background
background-color: rgba(255, 255, 255, 0.95);

.onscroll .header.js-fixed.region--black-background
background-color: rgba(29, 29, 29, 0.95);

.onscroll .header.js-fixed.region--gray-background
background-color: rgba(244, 244, 244, 0.95);

.fixed-header-enabled.onscroll .header__container,
.fixed-header-enabled.onscroll .header-second,
.fixed-header-enabled.onscroll .header-third,
.fixed-header-enabled.onscroll .header-first,
.fixed-header-enabled.onscroll .header-container ul.menu
-webkit-transition: ease-in-out 0.2s;
-o-transition: ease-in-out 0.2s;
transition: ease-in-out 0.2s;

.fixed-header-enabled.onscroll .header__container
padding: 5px 0;

.fixed-header-enabled.onscroll .header__section ul.menu
padding-top: 10px;

.fixed-header-enabled.onscroll .header__section .field--mt-dropdowns-block
padding-top: 14px;

@media (max-width: 991px)
.onscroll .header__container > .row > div
display: none;

.onscroll .header__container > .row > div:last-of-type
display: block;

.onscroll .header-container .content > ul.menu
padding-top: 10px;


@media (max-width: 767px)
.onscroll .header.js-fixed
display: none;




JavaScript



(function ($, Drupal) 
Drupal.behaviors.mtWaypointsFixedHeader =
attach: function (context, settings)
$(context).find(".header-container .header").once('mtWaypointsFixedHeaderInit').each(function(index, item)
var sticky = new Waypoint.Sticky (
element: $('.header-container .header')[0],
stuckClass: 'js-fixed',
handler: function(direction)
if (Waypoint.viewportWidth() > 752)
$('body', context).toggleClass('onscroll');
else
$('body', context).removeClass('onscroll');

var topValue = $('body').css('padding-top');
$(".header.js-fixed").css("top", topValue);
,
offset: function()
var offsetValue = parseInt($('body').css('padding-top')) - 1;
return offsetValue;

);
);

;
)(jQuery, Drupal);









share|improve this question






























    1















    I'm working with a Drupal 8.x template and I need to modify a sticky header that it get activated onscroll.



    The header is transparent when the page load and ones the user scroll down it has a white background and it get stuck at the top of the page (just as a sticky header normally works...)



    What I want to do it's to modify the code so it won't start transparent. I need it to have the white background from the start, as soon as the page loads and of course with the sticky function.



    These are the two codes i found that make the sticky header work. Hope someone can help me!



    CSS



    .onscroll.transparent-header-active .header-container.js-transparent-header .sticky-wrapper 
    height: 0 !important;

    .onscroll .header.js-fixed
    position: fixed;
    z-index: 499;
    top: 0;
    width: 100%;
    -webkit-box-shadow: 0 2px 14px rgba(100, 100, 100, 0.1), 0 2px 2px rgba(100, 100, 100, 0.1);
    box-shadow: 0 2px 14px rgba(100, 100, 100, 0.1), 0 2px 2px rgba(100, 100, 100, 0.1);

    .onscroll .header.js-fixed.region--white-background
    background-color: rgba(255, 255, 255, 0.95);

    .onscroll .header.js-fixed.region--black-background
    background-color: rgba(29, 29, 29, 0.95);

    .onscroll .header.js-fixed.region--gray-background
    background-color: rgba(244, 244, 244, 0.95);

    .fixed-header-enabled.onscroll .header__container,
    .fixed-header-enabled.onscroll .header-second,
    .fixed-header-enabled.onscroll .header-third,
    .fixed-header-enabled.onscroll .header-first,
    .fixed-header-enabled.onscroll .header-container ul.menu
    -webkit-transition: ease-in-out 0.2s;
    -o-transition: ease-in-out 0.2s;
    transition: ease-in-out 0.2s;

    .fixed-header-enabled.onscroll .header__container
    padding: 5px 0;

    .fixed-header-enabled.onscroll .header__section ul.menu
    padding-top: 10px;

    .fixed-header-enabled.onscroll .header__section .field--mt-dropdowns-block
    padding-top: 14px;

    @media (max-width: 991px)
    .onscroll .header__container > .row > div
    display: none;

    .onscroll .header__container > .row > div:last-of-type
    display: block;

    .onscroll .header-container .content > ul.menu
    padding-top: 10px;


    @media (max-width: 767px)
    .onscroll .header.js-fixed
    display: none;




    JavaScript



    (function ($, Drupal) 
    Drupal.behaviors.mtWaypointsFixedHeader =
    attach: function (context, settings)
    $(context).find(".header-container .header").once('mtWaypointsFixedHeaderInit').each(function(index, item)
    var sticky = new Waypoint.Sticky (
    element: $('.header-container .header')[0],
    stuckClass: 'js-fixed',
    handler: function(direction)
    if (Waypoint.viewportWidth() > 752)
    $('body', context).toggleClass('onscroll');
    else
    $('body', context).removeClass('onscroll');

    var topValue = $('body').css('padding-top');
    $(".header.js-fixed").css("top", topValue);
    ,
    offset: function()
    var offsetValue = parseInt($('body').css('padding-top')) - 1;
    return offsetValue;

    );
    );

    ;
    )(jQuery, Drupal);









    share|improve this question


























      1












      1








      1








      I'm working with a Drupal 8.x template and I need to modify a sticky header that it get activated onscroll.



      The header is transparent when the page load and ones the user scroll down it has a white background and it get stuck at the top of the page (just as a sticky header normally works...)



      What I want to do it's to modify the code so it won't start transparent. I need it to have the white background from the start, as soon as the page loads and of course with the sticky function.



      These are the two codes i found that make the sticky header work. Hope someone can help me!



      CSS



      .onscroll.transparent-header-active .header-container.js-transparent-header .sticky-wrapper 
      height: 0 !important;

      .onscroll .header.js-fixed
      position: fixed;
      z-index: 499;
      top: 0;
      width: 100%;
      -webkit-box-shadow: 0 2px 14px rgba(100, 100, 100, 0.1), 0 2px 2px rgba(100, 100, 100, 0.1);
      box-shadow: 0 2px 14px rgba(100, 100, 100, 0.1), 0 2px 2px rgba(100, 100, 100, 0.1);

      .onscroll .header.js-fixed.region--white-background
      background-color: rgba(255, 255, 255, 0.95);

      .onscroll .header.js-fixed.region--black-background
      background-color: rgba(29, 29, 29, 0.95);

      .onscroll .header.js-fixed.region--gray-background
      background-color: rgba(244, 244, 244, 0.95);

      .fixed-header-enabled.onscroll .header__container,
      .fixed-header-enabled.onscroll .header-second,
      .fixed-header-enabled.onscroll .header-third,
      .fixed-header-enabled.onscroll .header-first,
      .fixed-header-enabled.onscroll .header-container ul.menu
      -webkit-transition: ease-in-out 0.2s;
      -o-transition: ease-in-out 0.2s;
      transition: ease-in-out 0.2s;

      .fixed-header-enabled.onscroll .header__container
      padding: 5px 0;

      .fixed-header-enabled.onscroll .header__section ul.menu
      padding-top: 10px;

      .fixed-header-enabled.onscroll .header__section .field--mt-dropdowns-block
      padding-top: 14px;

      @media (max-width: 991px)
      .onscroll .header__container > .row > div
      display: none;

      .onscroll .header__container > .row > div:last-of-type
      display: block;

      .onscroll .header-container .content > ul.menu
      padding-top: 10px;


      @media (max-width: 767px)
      .onscroll .header.js-fixed
      display: none;




      JavaScript



      (function ($, Drupal) 
      Drupal.behaviors.mtWaypointsFixedHeader =
      attach: function (context, settings)
      $(context).find(".header-container .header").once('mtWaypointsFixedHeaderInit').each(function(index, item)
      var sticky = new Waypoint.Sticky (
      element: $('.header-container .header')[0],
      stuckClass: 'js-fixed',
      handler: function(direction)
      if (Waypoint.viewportWidth() > 752)
      $('body', context).toggleClass('onscroll');
      else
      $('body', context).removeClass('onscroll');

      var topValue = $('body').css('padding-top');
      $(".header.js-fixed").css("top", topValue);
      ,
      offset: function()
      var offsetValue = parseInt($('body').css('padding-top')) - 1;
      return offsetValue;

      );
      );

      ;
      )(jQuery, Drupal);









      share|improve this question














      I'm working with a Drupal 8.x template and I need to modify a sticky header that it get activated onscroll.



      The header is transparent when the page load and ones the user scroll down it has a white background and it get stuck at the top of the page (just as a sticky header normally works...)



      What I want to do it's to modify the code so it won't start transparent. I need it to have the white background from the start, as soon as the page loads and of course with the sticky function.



      These are the two codes i found that make the sticky header work. Hope someone can help me!



      CSS



      .onscroll.transparent-header-active .header-container.js-transparent-header .sticky-wrapper 
      height: 0 !important;

      .onscroll .header.js-fixed
      position: fixed;
      z-index: 499;
      top: 0;
      width: 100%;
      -webkit-box-shadow: 0 2px 14px rgba(100, 100, 100, 0.1), 0 2px 2px rgba(100, 100, 100, 0.1);
      box-shadow: 0 2px 14px rgba(100, 100, 100, 0.1), 0 2px 2px rgba(100, 100, 100, 0.1);

      .onscroll .header.js-fixed.region--white-background
      background-color: rgba(255, 255, 255, 0.95);

      .onscroll .header.js-fixed.region--black-background
      background-color: rgba(29, 29, 29, 0.95);

      .onscroll .header.js-fixed.region--gray-background
      background-color: rgba(244, 244, 244, 0.95);

      .fixed-header-enabled.onscroll .header__container,
      .fixed-header-enabled.onscroll .header-second,
      .fixed-header-enabled.onscroll .header-third,
      .fixed-header-enabled.onscroll .header-first,
      .fixed-header-enabled.onscroll .header-container ul.menu
      -webkit-transition: ease-in-out 0.2s;
      -o-transition: ease-in-out 0.2s;
      transition: ease-in-out 0.2s;

      .fixed-header-enabled.onscroll .header__container
      padding: 5px 0;

      .fixed-header-enabled.onscroll .header__section ul.menu
      padding-top: 10px;

      .fixed-header-enabled.onscroll .header__section .field--mt-dropdowns-block
      padding-top: 14px;

      @media (max-width: 991px)
      .onscroll .header__container > .row > div
      display: none;

      .onscroll .header__container > .row > div:last-of-type
      display: block;

      .onscroll .header-container .content > ul.menu
      padding-top: 10px;


      @media (max-width: 767px)
      .onscroll .header.js-fixed
      display: none;




      JavaScript



      (function ($, Drupal) 
      Drupal.behaviors.mtWaypointsFixedHeader =
      attach: function (context, settings)
      $(context).find(".header-container .header").once('mtWaypointsFixedHeaderInit').each(function(index, item)
      var sticky = new Waypoint.Sticky (
      element: $('.header-container .header')[0],
      stuckClass: 'js-fixed',
      handler: function(direction)
      if (Waypoint.viewportWidth() > 752)
      $('body', context).toggleClass('onscroll');
      else
      $('body', context).removeClass('onscroll');

      var topValue = $('body').css('padding-top');
      $(".header.js-fixed").css("top", topValue);
      ,
      offset: function()
      var offsetValue = parseInt($('body').css('padding-top')) - 1;
      return offsetValue;

      );
      );

      ;
      )(jQuery, Drupal);






      javascript css drupal-8






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 27 at 5:23









      HawkHawk

      1179 bronze badges




      1179 bronze badges

























          1 Answer
          1






          active

          oldest

          votes


















          0














          It looks like you need to add the background color to the .header css class before the .onscroll class is added by javascript. Maybe adding this to your css might do it:



          .header 
          background-color: rgba(244, 244, 244, 0.95);



          If that's not working, try adding it with !important like so:



          .header 
          background-color: rgba(244, 244, 244, 0.95) !important;






          share|improve this answer




















          • 1





            it worked... still going to need a lot of modification to make look right... but I'll work on it...

            – Hawk
            Mar 27 at 6:30










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55370303%2fcss-sticky-header-onscroll%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          It looks like you need to add the background color to the .header css class before the .onscroll class is added by javascript. Maybe adding this to your css might do it:



          .header 
          background-color: rgba(244, 244, 244, 0.95);



          If that's not working, try adding it with !important like so:



          .header 
          background-color: rgba(244, 244, 244, 0.95) !important;






          share|improve this answer




















          • 1





            it worked... still going to need a lot of modification to make look right... but I'll work on it...

            – Hawk
            Mar 27 at 6:30















          0














          It looks like you need to add the background color to the .header css class before the .onscroll class is added by javascript. Maybe adding this to your css might do it:



          .header 
          background-color: rgba(244, 244, 244, 0.95);



          If that's not working, try adding it with !important like so:



          .header 
          background-color: rgba(244, 244, 244, 0.95) !important;






          share|improve this answer




















          • 1





            it worked... still going to need a lot of modification to make look right... but I'll work on it...

            – Hawk
            Mar 27 at 6:30













          0












          0








          0







          It looks like you need to add the background color to the .header css class before the .onscroll class is added by javascript. Maybe adding this to your css might do it:



          .header 
          background-color: rgba(244, 244, 244, 0.95);



          If that's not working, try adding it with !important like so:



          .header 
          background-color: rgba(244, 244, 244, 0.95) !important;






          share|improve this answer













          It looks like you need to add the background color to the .header css class before the .onscroll class is added by javascript. Maybe adding this to your css might do it:



          .header 
          background-color: rgba(244, 244, 244, 0.95);



          If that's not working, try adding it with !important like so:



          .header 
          background-color: rgba(244, 244, 244, 0.95) !important;







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 27 at 5:35









          Matthew T RaderMatthew T Rader

          1168 bronze badges




          1168 bronze badges










          • 1





            it worked... still going to need a lot of modification to make look right... but I'll work on it...

            – Hawk
            Mar 27 at 6:30












          • 1





            it worked... still going to need a lot of modification to make look right... but I'll work on it...

            – Hawk
            Mar 27 at 6:30







          1




          1





          it worked... still going to need a lot of modification to make look right... but I'll work on it...

          – Hawk
          Mar 27 at 6:30





          it worked... still going to need a lot of modification to make look right... but I'll work on it...

          – Hawk
          Mar 27 at 6:30








          Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







          Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.



















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55370303%2fcss-sticky-header-onscroll%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

          은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현