Home > Software engineering >  How to ensure span's content grow to the right instead of left in CSS
How to ensure span's content grow to the right instead of left in CSS

Time:10-21

I have a span tag and have such css styles:

position: absolute;
top: 5px;
right: 125px;
font-size: 9px;
color: #fff;
font-weight: 700;
background-color: #19b385;
display: inline-block;
padding: 1px 5px;
min-width: 12px;
border-radius: 50px;
user-select: none;

But the problem is if I add more and more content like <span>100000</span> then it grows to the left but I want it to grow to the right

CodePudding user response:

If you set the left position value instead of the right then it will be fixed at the left side so should grow to the right.

Try left: calc(100% - 125px) or something like that.

  • Related