Interactive button - Including both title and contact information

I attempted to design a button that includes both a label and a numerical value.

To create space between the label and the number, I used padding. However, when the number is large, it ends up overlapping the label.

Is there a method to center the label on the button and ensure that the button remains fully responsive regardless of the displayed number?

DEMO

Html

  <div class="d-flex justify-content-md-center flex-nowrap" style="margin-top:50px">
    <a style="color: #51CC8B;" class="btnP">Prepared
      <span class="nav-link btn-glyphicon1">1500</span>
    </a>
  </div>

Css

.btnP {
  padding-right: 50px;
  padding-left: 8px;
  height: 24px;
  transition: all 0.3s ease 0s;
  cursor: pointer;
  white-space: nowrap;
  position: relative;
  text-decoration: none;
  display: flex;
  align-items: center;
  margin-right: 16px;
  text-align: center;
  font-weight: bold;
  font-size: 13px;
  font-family: 'Noto Sans', sans-serif;
  line-height: 6px;
  letter-spacing: 0;
  color: #51CC8B;
  -ms-border-radius: 16px;
  -o-border-radius: 16px;
  -moz-border-radius: 16px;
  -webkit-border-radius: 16px;
  border-radius: 16px;
  border-width: none;
  background: #EDFAF3;
  outline: none;
}

.btn-glyphicon1 { 
  padding: 8px;
  line-height: 6px;
  text-align: center;
  border-radius: 16px;
  right: 0;
  position: absolute;
  background: #DDF6E9 0% 0% no-repeat padding-box;
  font-size: 13px;
  font-family: 'Noto Sans', sans-serif;
  letter-spacing: 0;
  color: #51CC8B;
}

https://i.sstatic.net/N09Yd.png

PROBLEM

https://i.sstatic.net/x46Si.png

As depicted in the image, the number overlaps the label :( I am looking for a solution where the text always stays centered on the button and adjusts its width based on the number size.

Any assistance would be appreciated!

Answer №1

.btnP {
  padding-right: 50px;
  padding-left: 8px;
  height: 24px;
  transition: all 0.3s ease 0s;
  cursor: pointer;
  white-space: nowrap;
  position: relative;
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content:center;
  margin-right: 16px;
  text-align: center;
  font-weight: bold;
  font-size: 13px;
  font-family: 'Noto Sans', sans-serif;
  line-height: 6px;
  letter-spacing: 0;
  color: #51CC8B;
  -ms-border-radius: 16px;
  -o-border-radius: 16px;
  -moz-border-radius: 16px;
  -webkit-border-radius: 16px;
  border-radius: 16px;
  border-width: none;
  background: #EDFAF3;
  outline: none;

}

.btn-glyphicon1 { 
  padding: 8px;
  line-height: 6px;
  
  border-radius: 16px;
  
  align-items:center;
  background: #DDF6E9 0% 0% no-repeat padding-box;
  font-size: 13px;
  font-family: 'Noto Sans', sans-serif;
  margin-left:20px;
  color: #51CC8B;
}
<div class="d-flex justify-content-md-center flex-nowrap" style="margin-top:50px">
    <a style="color: #51CC8B;" class="btnP">Ready
      <span class="nav-link btn-glyphicon1">1500</span>
    </a>
  </div>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Center-aligned navigation bar with all elements except for one positioned on the right side

Currently, I am attempting to center 4 elements next to each other while having one element float to the right using a flex-based solution. The ideal outcome would be for the floated element to remain in place when resizing the browser, with the other 4 e ...

Remove the new line break at the top of the text and replace it with the remaining text

[text area control has a new line break that needs to be removed and replaced with the remaining string like image two][1] This image illustrates ...

Aligning text in the middle of an image both vertically and horizontally

I've been experimenting with different methods to vertically align caption text in the middle of an image, but I haven't had much luck. I've tried using table-cells and other techniques, without success! Currently, I have an <li> elem ...

Switch your attention to the following input text using AngularJS

In my controller, I have an object variable called `myObject` with 3 input text fields in the user interface. I am looking for a way to automatically shift the focus to the next input field once the current one reaches its maximum length. var myObject = ...

How can custom selectors be created in LESS?

Let me provide an example of my desired approach. :all() { &, &:link, &:visited, &:active, &:focus } The concept above involves a 'custom selector' that encompasses all pseudo-classes of an anchor tag, e ...

Incorporating an HTML header into a QNetworkReply

I have implemented a customized QNetworkAccessManager and subclassed QNetworkReply to handle unique AJAX requests from a JavaScript application. It is functioning mostly as expected, but I have encountered an issue where my network replies seem to be missi ...

Optimal approach for creating a CSS button with a dynamic size, gradient background and arrow design

I'm utilizing the Zurb Foundation framework and aiming to create dynamic call-to-action buttons with varying sizes, text, a background gradient, and a right-pointing arrow. There are three potential approaches I've envisioned: Employ an a el ...

What methods did 9gag use to prevent pictures from being easily replicated?

For the longest time, I would simply right-click and select "save picture" to save an image from a post. However, I've noticed a recent change where now I have to open the source in order to do anything with the picture. What could possibly be differe ...

Reveal or Conceal Information Based on Scroll Location

Can anyone help me recreate the interactive effect seen in the blue circles on ? When scrolled into view, the content within these circles changes to reflect the post being focused on. I'm specifically looking for guidance on how to implement this us ...

Tips for loading all background images simultaneously

I just created my first website page with a few background images that crossfade. However, I am experiencing an issue where the next background image takes some time to load during the crossfading effect if the page is not cached on the user's comput ...

Show an image based on a query parameter

Currently, I am developing a PHP project and I am facing an issue with loading an image from a query string. Here is the code snippet I am using: <img src="load_image.php?name=Profile_Photo_Small" /> Is there anyone who can help me out with this pro ...

Ensuring Form Security with JQuery Validation

Hello everyone, I'm currently working on a login form with jQuery validation to ensure that the user ID and password entered are valid. So far, this is what I have implemented: <script type="text/javascript" src="http://ajax.googleapis.com/ajax/l ...

Interactive JavaScript Slider for Customizing Selection

Recently, I came across a range slider and I am trying to make it more dynamic. The current JavaScript code has hardcoded references to specific HTML elements, and I want to have multiple sliders on my HTML page, each functioning independently. The code sn ...

Creating responsive images using Bootstrap CSS framework

I have been focusing on optimizing the banner below the navigation menu on this website. My goal is to make it responsive so that the player in the banner remains visible even when scaling down to iPhone size portrait. You can find the code for this secti ...

The navigation in Ionic is having trouble loading a specific page

As a newcomer to the world of Ionic, I am embarking on creating an ion-nav-view following the guidance provided in the tutorial here. After carefully constructing 2 pages and configuring an Angular conf file, I encountered an error message while loading th ...

Modify the CSS preferences using an object that has been obtained

After the user selects options from a form, I am trying to update my CSS using the settings received from an object. However, I am unsure of how to implement this layout change. Here is a glimpse of my template: div class="btn btn-primary" ng-click= ...

Styling Challenge: Positioning a Button to the Left of Another Button in a Corner

--------------------------------------------- | custom text | | custom test | | custom content | | unique words | | interesting phrases ...

Is it possible to add rounded corners to a Bootstrap 4 container using the container class

Is there a way to achieve a div with both a container class from Bootstrap and rounded corners? <div class="container rounded"> <div class="row"> <div class="col">Approver:</div> </div> </div> Despite using th ...

Placing an eye icon on the password input field for optimal visibility and positioning

I am currently working on a Node.js project and I am attempting to incorporate an eye icon using Bootstrap into the password input field for visibility. Below is the code snippet of my input field: <div class="container"> <form ...

The website is unresponsive to the media query

Currently, I am working on a project using Windows 10, Codeigniter, jQuery, and Firefox 43.0.4. However, I am facing an issue that is quite baffling to me. My goal is to apply styles specifically for an iPad-sized window, so I have implemented the followin ...