- Change Navbar Text Color on Scroll
- How to Change Navbar Text Color on Scroll
- The CSS Styles for Navbar
- jQuery Function.
- Change text color while scrolling
- Join the world’s most active Tech Community!
- Welcome back to the World’s most active Tech Community!
- Subscribe to our Newsletter, and get personalized recommendations.
- TRENDING CERTIFICATION COURSES
- TRENDING MASTERS COURSES
- COMPANY
- WORK WITH US
- DOWNLOAD APP
- CATEGORIES
- CATEGORIES
- CSS Change color of text when scrolling over/under another element
- CSS Style
- HTML Body
- Related
- 16+ Text Scrolling Animation Code Snippets
- Text Scrolling Animation Code Snippets
- Scroll Blur
- Interactive Text Scroll
- On Hover Text Scroll
- Dual Color Text Scroll Effect
- Fade-in Scroll
- Text Scroll Map
- Background Effect Text Scrolling
- Zoom-in Text Scroll
- Text Scroll-highlight
- Text Scroll with Length Indicator
- Text Scroll Destroy
- Fade-mask
- Random Text Scroll
- Javascript Text Scroll Effect
- Wave Text Scroll
- Continuous Dual Color
- Parallax Text Scroll
- Background Text Scroll
- Static CSS Text Scroll
Change Navbar Text Color on Scroll
In this tutorial, we are going to create a simple navbar and change its background & text color on the scroll. We’ll create a sticky (fixed) navbar to see this color-changing effect in real-time.
Before moving forward, I’ll suggest you check the final output of this navbar project on the demo page. Well! you may have noticed both background and navbar text color change after some scroll. Don’t worry if you want to change the only text color or background color only, you can do that with a minor change (I explained below how to do that).
The coding concept for this navbar is simple and straightforward. You just need to create a navbar HTML, some CSS styles, and a little jQuery function to add a class name to change the background and text color. OK! let’s get started with coding.
How to Change Navbar Text Color on Scroll
First, we need a navbar in order to change the navbar text color. So, create a nav element with the class name «navbar» and place your list of links inside it. You can also add other elements in your navbar like logo, a search box, or whatever you want. So, a basic HTML structure for navbar is as follows:
If you already have a navbar, you just need to add a unique class name or id that we’ll use in jQuery function to change the navbar text color.
The CSS Styles for Navbar
In CSS, first of all, set some style for the navbar. Define its position as fixed in order to make it sticky on the top of the screen. Set a background color that will display before the scroll. The other values like height and box-shadow can be defined according to your needs.
After that, create CSS styles for the navbar’s unorder list. Hide the default list bullets by CSS list-style-type property. Similarly, display the navbar list items as inline-block in order to show them in horizontally.
Now, its time to style the links of the navbar. Like navbar list items, also display them as inline-block. In the following selector for hyperlinks, you can set a text color that will display before scroll.
Set a background color for the hovered links. Define transition duration for smoothness.
Now, define a class name, set background, and text color that you want to apply on the window scroll. We’ll add this class name in the navbar using a jQuery function. If you want to change the only text color then don’t define CSS background property.
jQuery Function.
Before the following jQuery code, you need to load the main jQuery library by adding the following CDN link into your HTML.
Finally, create a window scroll function and add a “blue” class after some scroll using if condition. Similarly, remove the class name using else condition.
$(document).ready(function() < $(window).scroll(function()< var scroll = $(window).scrollTop(); if (scroll >300) < $(".navbar").css("background" , "blue"); >else < $(".navbar").css("background" , "#333"); >>) >)
That’s all! I hope you’ve successfully created the navbar. If you have any questions or suggestions let me know by comment below.
Change text color while scrolling
- All categories
ChatGPT (11)
Apache Kafka (84)
Apache Spark (596)
Azure (145)
Big Data Hadoop (1,907)
Blockchain (1,673)
C# (141)
C++ (271)
Career Counselling (1,060)
Cloud Computing (3,469)
Cyber Security & Ethical Hacking (162)
Data Analytics (1,266)
Database (855)
Data Science (76)
DevOps & Agile (3,608)
Digital Marketing (111)
Events & Trending Topics (28)
IoT (Internet of Things) (387)
Java (1,247)
Kotlin (8)
Linux Administration (389)
Machine Learning (337)
MicroStrategy (6)
PMP (423)
Power BI (516)
Python (3,193)
RPA (650)
SalesForce (92)
Selenium (1,569)
Software Testing (56)
Tableau (608)
Talend (73)
TypeSript (124)
Web Development (3,002)
Ask us Anything! (66)
Others (2,231)
Mobile Development (395)
UI UX Design (24)
Join the world’s most active Tech Community!
Welcome back to the World’s most active Tech Community!
Subscribe to our Newsletter, and get personalized recommendations.
Sign up with Google
Signup with Facebook
Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP
TRENDING CERTIFICATION COURSES
- DevOps Certification Training
- AWS Architect Certification Training
- Big Data Hadoop Certification Training
- Tableau Training & Certification
- Python Certification Training for Data Science
- Selenium Certification Training
- PMP® Certification Exam Training
- Robotic Process Automation Training using UiPath
- Apache Spark and Scala Certification Training
- Microsoft Power BI Training
- Online Java Course and Training
- Python Certification Course
TRENDING MASTERS COURSES
- Data Scientist Masters Program
- DevOps Engineer Masters Program
- Cloud Architect Masters Program
- Big Data Architect Masters Program
- Machine Learning Engineer Masters Program
- Full Stack Web Developer Masters Program
- Business Intelligence Masters Program
- Data Analyst Masters Program
- Test Automation Engineer Masters Program
- Post-Graduate Program in Artificial Intelligence & Machine Learning
- Post-Graduate Program in Big Data Engineering
COMPANY
WORK WITH US
DOWNLOAD APP
CATEGORIES
CATEGORIES
- Cloud Computing
- DevOps
- Big Data
- Data Science
- BI and Visualization
- Programming & Frameworks
- Software Testing © 2023 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved. Terms & ConditionsLegal & Privacy
CSS Change color of text when scrolling over/under another element
The following tutorial shows you how to use CSS to do «CSS Change color of text when scrolling over/under another element».
CSS Style
The CSS style to do «CSS Change color of text when scrolling over/under another element» is
body !-- w ww . d e mo 2 s . c o m --> height:1000px; > .text < text-transform:uppercase; position:absolute; top:80%; font-size:50px; font-weight:bold; text-align:center; width:100%; color:gray; z-index:2; left:0; mix-blend-mode:difference; > .box < width:60%; position:fixed; transform:translate(-50%, 0); z-index:1; left:50%; top:0; height:100px; background:#AAAAAA; >
HTML Body
body> div >"box"> div >"text"> Lorem ipsum
The following iframe shows the result. You can view the full source code and open it in another tab.
html> head> meta name="viewport" content="width=device-width, initial-scale=1"> script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.0/jquery.js" > style id="compiled-css" type="text/css"> body !-- w w w . d e m o 2 s . co m--> height: 1000px; > .text < text-transform: uppercase; position: absolute; top: 80%; font-size: 50px; font-weight: bold; text-align: center; width: 100%; color: gray; z-index: 2; left: 0; mix-blend-mode: difference; > .box < width: 60%; position: fixed; transform: translate(-50%, 0); z-index: 1; left: 50%; top: 0; height: 100px; background: #AAAAAA; > body> div >"box"> div >"text">Lorem ipsum
Related
- CSS change color from text except everything is between tags
- CSS change color from text except everything is between tags (Demo 2)
- CSS Change color of one character in a text box HTML/CSS
- CSS Change color of text when scrolling over/under another element
- CSS Change color of text when scrolling over/under another element (Demo 2)
- CSS Change color when text passes under transparent div
- CSS Change colour of placeholder text underline
demo2s.com | Email: | Demo Source and Support. All rights reserved.
16+ Text Scrolling Animation Code Snippets
Nowadays everyone needs something cool and attractive in every sector. It is also applicable in terms of designing. Animation has great role to make the design look cool and attractive. There are different types of animation that can be applied in different sections. In this article we are providing the best text scrolling animation code snippets.
Text scrolling animation is very much applicable in the content of web page. This animation helps to make the scroll of text look attractive by replacing the simple text scrolling with advance text scrolling animations. This animation not only makes you content attractive but makes your whole website looks cool and advance.
Text Scrolling Animation Code Snippets
There are lots of text scrolling animation examples which is easily available on the internet. Among those animation only some of them are better. Here are the list of the 16+ Text Scrolling Animation Code Snippets which helps you with best text scrolling design.
Scroll Blur
Scroll Blur is blurry animation. In this animation, text appears blur when it is scrolled up or down. This attractive animation is pen by Ignacio Correia.
Demo and Source Code
Interactive Text Scroll
Interactive text Scroll is one of the pleasing animation example for text scrolling. The text moves horizontally on opposite direction to mouse cursor with italic font style.
Code and Demo
On Hover Text Scroll
On hover text scroll is simple but very useful text scrolling animation examples. The text scrolls horizontally toward left direction on hovering the cursor.
Dual Color Text Scroll Effect
Dual Color is beautiful text scrolling animation. Both color and background color of the text changes when it is scrolled in vertical direction.
View Demo and Code
Fade-in Scroll
Fade-in Scroll is attractive animation for Text Scrolling animation examples. The animation contains the fade-in effect. The text smoothly appears when it scrolled in vertical direction.
Demo and Code
Text Scroll Map
Text Scroll Map is created using HTML, CSS and JavaScript. This is very useful text scrolling animation. You can manually drag the text area to display the content.
Code and Demo
Background Effect Text Scrolling
This animation is one of beautiful animation among the text scrolling animation. The background color changes when it is scrolled in the vertically up or down.
Zoom-in Text Scroll
Zoom-in text scroll is simple text scrolling animation. The text of this animation appears with zoom effect when the text scrolls in vertical direction.
Demo and Code
Text Scroll-highlight
The text of this animation appears with highlighted color. The color of the text changes as the text scrolls in vertical direction.
Code and Demo
Text Scroll with Length Indicator
There is changes in vertical as well as horizontal position of the text when it scrolls in vertical direction. The animation is a bit unique and stylish and is pen by Jonathan Haggard.
Code and Demo
Text Scroll Destroy
This animation is a bit different text scrolling animation. The text in this animation destroys when text is scroll in vertical direction.
Demo and Code
Fade-mask
Fade-mask is a text scrolling animation which is similar to fade-in. This animation is simple and attractive as text appears and disappears with fade effect.
Code and Demo
Random Text Scroll
The text in this animation scrolls randomly in vertical direction. This attractive animation is pen by Cecile Lafont.
Code and Demo
Javascript Text Scroll Effect
This animation is combination of HTML, CSS and JavaScript. The text in this animation appears continuously to complete the whole sentence. This animation is pen by Craig.
Code and Demo
Wave Text Scroll
The text in this animation appears in wave style. The text flows horizontally left to right with the wave effect. This stylist animation is pen by Anthony Del Ciotto.
Code and Demo
Continuous Dual Color
Continuous dual color animation is beautiful text scrolling animation. The text scrolls from right to left direction horizontally by changing its color.
Code and Demo
Parallax Text Scroll
Parallax text scroll is amazing text scrolling animation. The text in this animation scrolls upward and slightly disappears after appearance of below content.
Demo and Code
Background Text Scroll
The text in this animation scrolls in vertical direction along with the change in background color. This is simple and widely used animation in web pages.
Demo and Code
Static CSS Text Scroll
Static Css text scroll is very cool animation where the text is replaced with the new content in the stylish way. This animation is pen by Baltazar Parra.
Code and Demo
Conclusion
In Conclusion, the text scrolling animation helps in making your website cool and advance. every animation on this list are equally attractive. The only point is that it should be applicable with the correct requirement. Almost every animation of this list is taken from code pen.