If padding is included, the width of an element will be affected when using rem

I am facing an issue in my project. Whenever I try to insert a custom font-size at the html level, the red badges get deformed when there is padding (p-6) on the first line of code. Can someone assist me with this problem? I am using Tailwind CSS, but even if I include the width in the style exclusively with rem, this error still occurs.

Check out the demo here

Answer №1

Subpixel rendering is the key factor here. When using a 13px font-size at the html level, the width and height adjust to 9.75px.

To solve this issue, one should opt for a larger value and then scale it accordingly.

Check out the Demo

In my case, I utilized w-6 h-6 ring-8 scale-50 instead of w-3 h-3 ring-4, which resulted in a perfect display.

html {
  font-size: 13px;
}
<script src="https://cdn.tailwindcss.com"></script>

<div class="w-screen h-screen bg-neutral-50">
  <header class="flex flex-row bg-white p-6">
    <div class="flex-1 flex flex-row justify-end space-x-2">
      <div class="relative inline-block">
        <div class="w-12 h-12 bg-gray-100 rounded-full"></div>
        <div class="w-6 h-6 scale-50 bg-red-500 rounded-full ring-8 ring-white absolute top-0 right-0 origin-top-right"></div>
      </div>
      <div class="relative inline-block">
        <div class="w-12 h-12 bg-gray-100 rounded-full"></div>
        <div class="w-6 h-6 scale-50 bg-red-500 rounded-full ring-8 ring-white absolute top-0 right-0 origin-top-right"></div>
      </div>
      <div class="relative inline-block">
        <div class="w-12 h-12 bg-gray-100 rounded-full"></div>
        <div class="w-6 h-6 scale-50 bg-green-500 rounded-full ring-8 ring-white absolute bottom-0 right-0 origin-bottom-right"></div>
      </div>
    </div>
  </header>
</div>

Explore the Related Answer

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

Utilize flex to position content at the bottom

My layout features a fixed header and footer, positioned at the top and bottom respectively. The content section in between fills the remaining space, with a scrollbar available if the content extends beyond the area. <div id="app"> <d ...

Display one div and conceal all others

Currently, I am implementing a toggle effect using fadeIn and fadeOut methods upon clicking a button. The JavaScript function I have created for this purpose is as follows: function showHide(divId){ if (document.getElementById(divID).style.display == ...

What is the best way to retrieve the value of a submitted button in a jQuery form submission?

I am facing an issue with my HTML code. Here is the structure: <form method="post" id="IssueForm" action="wh_sir_insert.php"> <input name='id[]' type='checkbox' class="selectable" value='$col[8]' /> <inpu ...

Is there a way to align the navigation menu options to the right side of the navbar?

I'm having trouble aligning the options in the navbar to the right side. Can anyone help me identify where I'm going wrong in my code? Here is the snippet I'm working with: <div> <nav class="navbar navbar-expand-lg navb ...

Combine collapse and popover in Bootstrap 3 for enhanced functionality

I'm facing some issues trying to use the badge separately from the collapse feature. $(function (e) { $('[data-toggle="popover"]').popover({html: true}) }) $('.badge').click($(function (e) { e.stopPropagation(); }) ) Check o ...

Exploring the Possibilities of Wordpress Search with Multiple Dropdown Options

Is it possible to search across multiple categories? For example, I have 4 dropdown menus: 1. City 2. Area 3. Month 4. Products/Services When a user visits my site, they will see a static page with 4 dropdown lists and a "search" button. After the user ...

Encountering a problem with quintus-all.js and need assistance

I am having an issue with my animation code. Can someone help me troubleshoot it? window.addEventListener('load', function(){ var Q =window.Q= Quintus().include("Sprites, Scenes,2D, Anim").setup({maximize:true}); Q.Sprite.extend(&apos ...

How to locate an element in Webdriver/Selenium when it lacks a class name, id, or css selector?

Within the search results displayed in groups of 7, you can find the address and phone number for each entry on the right side as follows: I need to extract both the address and phone number for each result. The challenge lies in how these elements are st ...

jsoup - locate element and delete it along with the element preceding it

In my Android app, I am working on extracting data from a stock market historical prices table. However, there are certain rows in the table that need to be removed for clarity. Specifically, I am trying to remove a row in the third tr. I have managed to r ...

Exploring ways to integrate Javascript and CSS into a Bootstrap lightbox modal dialog?

Can someone help me figure out how to use the bootstrap lightbox to display a form with specific CSS style and JavaScript code for the form? I'm having some trouble implementing it. I specifically need this setup because I am using Selectize.JS to cr ...

What is the best way to assign a dynamic width to a block element?

In my project, I am working with 30 elements that have the class .lollipop and are styled with line-height: 30px; height: 30px;. <a class="lollipop">Random text</a> <a class="lollipop">Random text longer</a> <a class="lollipop"& ...

Looking to transform an HTML table into a stylish CSS layout complete with a form submission button?

Recently, I've been delving into the world of CSS and PHP as I work on converting old code entirely into HTML and PHP with a touch of CSS. The visual aspect seems fine, but I've hit a roadblock with the submit form due to an IF statement in PHP. ...

Bullet-point Progress Indicator in Bootstrap

Seeking guidance on how to create a Bootstrap progress bar with dots incorporated, similar to the image linked below. Any tips or resources where I can learn more about this technique? https://i.stack.imgur.com/BF8RH.jpg .progress { width: 278px; he ...

Utilizing Vue.js i18n for a multi-line text display

Currently, I am implementing i18n single file component in order to provide translation support for my application. In order to achieve this, I have been utilizing the i18n tag as shown below: <i18n> { "fr": { "text": "Lore ...

Coding in PHP, JavaScript, and HTML allows builders

I am facing some difficulties in locating my specific question, so I will describe it here. Currently, I am working with an oracle database and integrating it into an HTML website using javascript and php. I have successfully displayed the php file, but th ...

Execute function upon changing the title of a list item using jQuery

Hey there, I've got a question for you. Is it possible to trigger an event when the title of a list element is changed? For example: <ul> <li id="li_1" title="40">40</li> </ul> So when the title attribute changes (coming ...

Stay up-to-date with the latest headlines on your Android device!

I am currently developing an Android application and I need to retrieve the most recent news from this specific page, specifically the tab labeled "NYHEDER": Once I have retrieved the news, I plan to display it on the app's screen. I have come acros ...

Working with jQuery, CSS, and functions to modify the current tag's class

Let's keep it brief and straightforward: Here is my HTML <div id="headerVideoControls" class="overlayElement"> <div id="videoMuteUnmute" onclick="muteUnmuteVideo('headerVideo')">mute button</div> </div> Edited ...

Tips for overlapping children in a column flex direction while maintaining the parents' positioning

Currently, I am working with two parent flex items, arranged with flex-direction: column. Within the first parent, there are two children. However, one of the children is optional and may be removed at times. I aim to have the optional child displayed on ...

What is the best way to extract a JSON object from a website search using getJSON or similar techniques?

Can anyone provide guidance on utilizing .getJSON() to access JSON-encoded information from a website that is being searched? I've implemented a Google Custom Search API for my site with the aim of retrieving the JSON file from the search results. Fo ...