Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Show number of notifications on icon

I have a notification icon (font-awesome) which shows the number of notifications.

I am having a problem trying to get the number to display in the correct position, as shown in see below image

enter image description here

I need the text to be smaller and move right and up a little... here is the code

.header .bubble {
  border-radius: 100%;
  height: 14px;
  width: 14px;
  background-color: rgba(226, 32, 91, 0.77);
  color: #ffffff;
  text-align: top;
  position: relative;
  top: 0px;
  float: right;
  right: -3px;
}

 <a href="javascript:;" id="notification-center" class="icon-set globe-fill" data-toggle="dropdown"><span class="bubble">2</span>

Can anyone help, I am new to this.

like image 845
Shane Avatar asked Aug 03 '15 10:08

Shane


People also ask

How do I get my app icon to show notification numbers?

If you want to change badge with number, you can be changed in NOTIFICATION SETTING on the notification panel or Settings > Notifications > App icon badges > Select Show with number.

How can I see the number of messages on WhatsApp icon?

Ensure badges are enabled in iPhone Settings: Go to iPhone Settings, tap WhatsApp > Notifications, turn Badges on or off. Reset notification settings: Go to WhatsApp Settings, tap Notifications > Reset Notification Settings.


1 Answers

example1: using background image

The best way to do this is to use position:absolute to child span of parent anchor.

a.notif {
  position: relative;
  display: block;
  height: 50px;
  width: 50px;
  background: url('http://i.imgur.com/evpC48G.png');
  background-size: contain;
  text-decoration: none;
}
.num {
  position: absolute;
  right: 11px;
  top: 6px;
  color: #fff;
}
<a href="" class="notif"><span class="num">2</span></a>

example2: using font awesome icon

If you want to use font-awesome icon

this is code for it

a.fa-globe {
  position: relative;
  font-size: 2em;
  color: grey;
  cursor: pointer;
}
span.fa-comment {
  position: absolute;
  font-size: 0.6em;
  top: -4px;
  color: red;
  right: -4px;
}
span.num {
  position: absolute;
  font-size: 0.3em;
  top: 1px;
  color: #fff;
  right: 2px;
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" />
<a class="fa fa-globe">
  <span class="fa fa-comment"></span>
  <span class="num">2</span>
</a>
like image 153
Suresh Karia Avatar answered Oct 11 '22 01:10

Suresh Karia