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;
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
add a comment |
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
add a comment |
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
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
javascript css drupal-8
asked Mar 27 at 5:23
HawkHawk
1179 bronze badges
1179 bronze badges
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
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;
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
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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;
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
add a comment |
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;
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
add a comment |
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;
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;
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
add a comment |
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
add a comment |
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.
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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