Vishal Panara Vishal Panara - 4 months ago 8
HTML Question

Notification does not showing on particular button

I have buttons with span class, I m facing a problem to show each span class above particular button. Like this imageThis. How can i do this?



.label{
position: absolute;
top: 2.5rem;
}

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://use.fontawesome.com/f574067864.js"></script>
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>

<body>
<hr>
<div class="container">
<button class="btn btn-default" type="submit">Button</button>
<span class="label label-success">4</span>

<button class="btn btn-default" type="submit">Button</button>
<span class="label label-success">5</span>

<button class="btn btn-default" type="submit">Button</button>
<span class="label label-success">6</span>
</div>
</body>
</html>





Thank you...

Answer

Try this

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />
    <script src="https://use.fontawesome.com/f574067864.js"></script>
    <!DOCTYPE html>
    <html>
    <head>
      <title></title>
    </head>
    <style>
    .sub-btn{
        position: relative;
    }
    .sub-btn span{
        position: absolute !important;
        right: 0;
        top: -15px !important;
    }
    </style>
    <body>
    <hr>
    <div class="container">
    <button class="btn btn-default sub-btn" type="submit">Button <span class="label label-success">4</span></button>


    <button class="btn btn-default sub-btn" type="submit">Button <span class="label label-success">5</span></button>


    <button class="btn btn-default sub-btn" type="submit">Button <span class="label label-success">6</span></button>

    </div>
    </body>
    </html>