I'm trying to make a custom notification badge with CSS/SCSS. I want to insert content from html attribute (data-badge) as in the HTML code, but when I call it on the CSS it shows nothing.
HTML
<ul id="nav-mobile" class="right hide-on-med-and-down">
<li>
<a href="#" class="nav-icons"><i class="material-icons" data-badge="4">info</i></a>
</li>
<li>
<a href="#" class="nav-icons"><i class="material-icons">email</i></a>
</li>
<li>
<a href="#" class="dropdown-button" data-activates="dropdown-user">
<div class="chip">
<img src="/images/personal.png" alt="Contact Person">
Jane Doe
<i class="material-icons right">arrow_drop_down</i>
</div>
</a>
</li>
</ul>
SCSS
a.nav-icons {
max-height: 60px !important;
i.material-icons {
max-height: 60px;
font-size: 2rem;
line-height: 60px;
&[data-badge] {
content: attr(data-badge);
position: relative;
color: #fff;
&::after {
content: attr(data-badge);
position: absolute;
background: red;
border-radius: 50%;
display: block;
padding: 0.3em;
color: black;
font-size: 12px;
max-height: 20px;
max-width: auto;
right: -10px;
top: 8px;
}
}
}
}
Or, please see this fiddle below.
https://jsfiddle.net/5gxudefb/3/
Thank you in advance