PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, June 30, 2022

[FIXED] How change titles color of my navbar when the user scrolls ? Prestashop

 June 30, 2022     css, javascript, prestashop     No comments   

Issue

I would like to change my color titles from my navigation bar when the user scrolls a bit. I work in Prestashop and we can add custom CSS and custom javascript to it.

I started by analyzing the id of the text of the navigation bar in the theme of my prestashop: enter image description here

Then I created this little javascript:

window.onscroll = function() {
    var title= document.getElementById('title-text');
    if ( window.pageYOffset > 100 ) {
        title.classList.add("white_menu");
    } 
}

and this css:

.white_menu{
color: white;
}

But it doesn't work :/ Did I forget something ?

Thanks in advance Malaury

enter image description here


Solution

Add this style in your CSS

.white_menu span {
    color: white;
}

Replace your JS with this one

window.onscroll = function () {
    var title = document.getElementById('header_menu');
    if (window.pageYOffset > 100) {
        title.classList.add("white_menu");
    } else {
        title.classList.remove("white_menu");
    }
}


Answered By - 54ka
Answer Checked By - Gilberto Lyons (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing