Notification bar is an area used to display recent updates and offers to user it is used in modern websites to display offers and updates to user it is fast and easy way to display information without sending user to different page.
In this tutorial we will create a simple Notification Bar using jQuery and CSS. You may also like Play Sound On Notification Using JavaScript And CSS
CHECK OUT THIS TUTORIAL LIVE DEMO →
To Create Notification Bar It Takes Only Two Steps:-
- Make a HTML file and define markup and scripting
- Make a CSS file and define styling
Step 1. Make a HTML file and define markup and scripting
We make a HTML file and save it with a name notification_bar.html
<html> <head> <script type="text/javascript" src="jquery.js"></script> <link rel="stylesheet" type="text/css" href="notification_bar_style.css"> <script> function notification() { $("#notification_div").slideToggle(300); } </script> </head> <body> <div id="wrapper"> <div id="notification_div"> <span>Yesterday - You Have One Notification Pending From Yesterday</span> <br> <span>Today - You have No Notifications On Today</span> </div> <p id="show_notification" onclick='notification();'>Click To Show/Hide Notification Bar</p> </div> </body> </html>
In this step we made a div for notification bar and a paragraph which is used to show and hide the notification whenever user clicks on it.
We use jQuery slideToggle() function to show hide notification bar you can use what you want.
Step 2. Make a CSS file and define styling
We make a CSS file and save it with a name notification_bar_style.css
body { width:100%; margin:0 auto; padding:0px; background-color:#A9D0F5; font-family:helvetica; } #wrapper { text-align:center; margin:0 auto; padding:0px; width:100%; } #notification_div { height:100px; margin:0px; background-color:#2E9AFE; display:none; padding:40px; } #notification_div span { padding:15px; background-color:#084B8A; color:#A9D0F5; border-radius:5px; } #show_notification { padding:12px; margin:0px; background-color:#0174DF; vertical-align:bottom; color:#E0ECF8; font-weight:bold; font-size:17px; border-top:10px solid #045FB4; border-bottom:10px solid #045FB4; cursor:pointer; }
In this step we give some general styling to notification bar and we hide the notification bar because we want to display the notification only when user clicks on notification para.
Thats all, this is how to create simple Notification Bar using jQuery and CSS. You can customize this code further as per your requirement. And please feel free to give comments on this tutorial.
Latest Tutorials
- Create Animated Skill Bar Using jQuery, HTML And CSS
- Simple And Best Responsive Web Design Using CSS Part 2
- Show Button On Hover Using HTML And CSS
- Material Design Login Form Using jQuery And CSS
- Animated Progress Bar Using jQuery And CSS
- Dynamic Drop Down Menu Using jQuery, Ajax, PHP And MySQL
- Get Website Statistics Using PHP, jQuery And MySQL
- HTML5 Login And Signup Form With Animation Using jQuery
- Facebook Style Homepage Design Using HTML And CSS
- View Webpage In Fullscreen Using jQuery