Answers for "css scrollbar background color"

CSS
1

change scrollbar color

.scrollable-element {
  scrollbar-color: red yellow; /* red is for the thumb and yellow is for the track */
}
Posted by: Guest on October-23-2020
1

change header background color on scroll css

/* 
    .active { background-color: #fff}
*/
$(function() {
    $(window).on("scroll", function() {
        if($(window).scrollTop() > 50) {
            $(".header").addClass("active");
        } else {
           $(".header").removeClass("active");
        }
    });
});
Posted by: Guest on August-28-2021
1

how to change background color on scroll

const [red, green, blue] = [69, 111, 225]
const section1 = document.querySelector('.section1')

window.addEventListener('scroll', () => {
  let y = 1 + (window.scrollY || window.pageYOffset) / 150
  y = y < 1 ? 1 : y // ensure y is always >= 1 (due to Safari's elastic scroll)
  const [r, g, b] = [red/y, green/y, blue/y].map(Math.round)
  section1.style.backgroundColor = `rgb(${r}, ${g}, ${b})`
})
Posted by: Guest on September-11-2021

Browse Popular Code Answers by Language