Want To Be A Blogger  →  Start A Blog  →  Increase Traffic  →  Make Money Online  →  Recommended Things

Create Simple Notification Bar Using jQuery And CSS

Friday, Dec 15, 2017

Tags:- jQuery HTML CSS


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


See Demo
Simple Notification Bar Using jQuery And CSS


To Create Notification Bar It Takes Only Two Steps:-

  1. Make a HTML file and define markup and scripting
  2. 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.

Subscribe Our Newsletter And Get Tutorials And Offers Via Email

About Me


Hello, My Name is Mudit Jain. I am a Web Developer, Professional Blogger and Digital Marketer from India. I am the founder of TalkersCode. I started this blog in february 2015 to help web developers & bloggers by providing easy and best tutorials, articles and offers for web developers and bloggers.