Aligning Counter on Icon

Asked

Viewed 480 times

2

How to do in a correct way where the counter is always in the same position as illustrated below

inserir a descrição da imagem aqui Here depending on the resolution it leaves the position

inserir a descrição da imagem aqui How I wish it would turn out

My Code

<!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>

  • Even using the Bootstrap database it is not possible to play your code correctly. Update the question with a code that can be reproduced.

  • Partner changed the code

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>

0

I believe it’s just the CSS, add a relative in to which is encompassing the spans and square with quantity using the Absolute.

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.