Aligning Counter on top of Icon

1

How to do it correctly where the counter is always in the same position as shown below

 Heredependingontheresolutionitleavestheposition

HowIwantedittostay

MyCode

<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

<!-- Tema opcional -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">


</head>

<body id="page-top" data-spy="scroll" data-target=".navbar-fixed-top">

<div class="row">
<div class="col-md-12" style="text-align: center;"><br /><br />

<a href="car.php"><span class="glyphicon glyphicon-envelope xs" style="font-size: 20px;" aria-hidden="true"></span>
<span class="label label-danger" style="position: 
absolute; z-index: 1; ">1</span>
</a>
</div>
</div>
</body>

</html>
    
asked by anonymous 02.07.2017 / 18:53

2 answers

0

Add a position: relative to the link.

<a href="car.php" style="position: relative;">

    <span class="glyphicon glyphicon-envelope xs" style="font-size: 20px;" aria-hidden="true"></span>
    <span class="label label-danger" style="position: absolute; z-index: 1; ">1</span>

</a>
    
25.08.2017 / 22:28
0

I think it's just CSS, add a relative in the a that is spanning the spans and position the square with the quantity using absolute.

a{
  position:relative;
}
.label{
  position:absolute;
  top:-15px;
  right:-12px;
}
    
26.08.2017 / 00:15