Each browser has its unique set of pseudo content properties

Currently, I am using custom CSS to style radio buttons but I've encountered an issue.

The checked radio circle is displaying at different positions in IE11, FF36, and Chrome. Please refer to the image below for a visual representation:

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

The CSS code I'm using to achieve this effect is as follows:

label {
    display: inline-block;
    cursor: pointer;
    position: relative;
    padding-left: 32px;
}

input[type=radio] {
    display: none;
}

label:before {
    content: "";
    display: inline-block;
    width: 23px;
    height: 22px;
    margin-right: 10px;
    position: absolute;
    left: 0;
    border:1px solid $grey;
    border-radius: 50px;
}

input[type=radio]:checked + label:before {
    content: "\25CF";
    border:1px solid $light-blue;
    color: $light-blue;
    font-size: 26px;
    text-align: center;
    line-height: 0rem;
    padding-top: 7px;
}   

If you have any suggestions on how to ensure consistency across all browsers, please share your ideas. Thank you!

Answer №1

I decided to take a different approach this time. Instead of relying on content and line height, I made the switch below:

label:before {
content: "";
display: inline-block;
width: 20px;
height: 20px;
margin-right: 10px;
position: absolute;
padding:1px;
left: 0;
border:1px solid black;
border-radius: 50px;
}

input[type=radio]:checked + label:before {
border:1px solid blue;
background-color:blue;
box-shadow: 0 0 0 3px #fff inset;
width: 20px;
height: 20px;
}

Check out the updated version on JS Fiddle

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

Tips for creating a responsive Youtube embedded video

Check out this website for a good example: If you take a look, you'll notice that the header youtube video is responsive - it automatically resizes when the window size changes. Here are the <iframe> codes: <iframe id="bluetube-player-1" fr ...

Select the even-numbered occurrences of a specific class in CSS using the nth-child()

I am encountering an issue with my table layout. The structure is similar to the following: <tbody> <tr class="row">...</tr> <tr class="row--expanded">...</tr> <tr class="row">...</ ...

.htaccess 404 not redirecting properly

I need help with the following code snippet: # Keep this line intact for mod_rewrite rules to function properly RewriteBase / ErrorDocument 404 /errors/404.php Despite having the file 404.php in the errors folder, it doesn't seem to be working as ...

html<script src="" and causing a redirect when button is clicked

My login.html page for logging in can be found in the design folder. <html> <head> <title>Login Page</title> <script src="../Script/login.js"> </script> </head> <body> <h3> Login</h3> ...

What changes should I make to my code in order to incorporate an additional level of submenu to my CSS-based dropdown menu?

Hello and thank you for your help, I currently have some CSS code that is working well for 3 levels of dropdown menus, but I am now in need of it to also support a 4th level. When I try to add the extra level by copying the 3rd level code and making adjus ...

Using CSS to Customize TextField Focus in NativeScript

How can the focus state of a textfield be controlled in NativeScript? I would like to change its style when a user taps into it and begins typing, such as altering the border or background. Is there a way to achieve this using only CSS or by adding a styla ...

Aligning text vertically within a textbox using CSS

Currently tackling a textbox with a background and wondering if there's a way to vertically center the text inside it. Note: Text is perfectly centered in Firefox, but in IE it appears too high for some reason. Have tried adjusting line-height, paddi ...

I am currently seeking a way to validate if a variable corresponds to the choice made in the dropdown menu. Any suggestions on how to accomplish this task?

I have put together a simple drop down menu. My goal is to grab the currently selected value from the drop down list, store it in a variable, and display it in the console. The ultimate objective is to compare that variable with another one to determine if ...

What is the most effective way to reduce the length of user input in a textarea and set limits on both the maximum

Is it possible to adjust the length of input and textarea and show the remaining words left? My goal is to have a total length of 200 characters for both input and textarea fields. <input type="text" id="b" name="b" value="Hi world !" maxlength="50"&g ...

Toggle Visibility of Multiple Divs with Onclick in jQuery

I am in need of creating a navigation system that can display or hide multiple divs depending on user interactions. My requirements are as follows: When a user clicks on any of the "options", I want a class called "selected" to be applied to the chosen it ...

The alignment of the floating left element is creating conflicts with the styling of other div

As I embark on a design project, I find myself juggling three divs for distinct products, alongside a payment method image div and a copyright div. The product divs are aligned to the left within their specific wrapper, ensuring they center and display sea ...

"Using Bootstrap to specifically align a grid of images in the center on any screen size

I'm currently utilizing bootstrap to center a group of social icons beneath an h1 text on all screen sizes. While I've managed to achieve this, there are two specific sizes where the alignment seems to be off. Here's a snapshot showing a sl ...

Validation in Bootstrap form does not appear when browser saved data is utilized

When data is saved in the browser, the bootstrap validation (green tick) does not display, but it works perfectly when the data is entered manually. <!doctype html> <html lang="en"> <head> <!-- Required meta tags and Bootst ...

The image fails to load once the AI-generated image is complete and the response process has concluded

After a long hiatus from development, I am diving back in and acknowledging the rustiness of my skills. Any syntax or formatting errors encountered are preemptively apologized for. Currently, I am immersed in a small web app project that involves taking a ...

Is it possible for Golang to operate solely with HTML, CSS, and JS without the use of a Front-End

Is it possible to develop an API using Golang and then display the content using only HTML, CSS, and JavaScript on a web browser? ...

html/css: Collapse container in a horizontal list due to white spaces

I am currently working on creating a horizontal menu for my website. While I have made progress, I am encountering two issues that are interfering with my design. I am exploring two potential solutions: 1). By using the following CSS: #menu li { displa ...

Navigation Menu with Tailwind CSS Hover Effects and Spacing

I'm trying to display the sub <ul> list on the first navigation item when hovering over it: https://i.sstatic.net/KNqcx.png Everything is working fine except sometimes (it's inconsistent) when you are between the padding of the first line ...

What impact does the use of CSS in emails have on various email clients and reading formats?

As I delve into customizing my very first (woocommerce) email template, I am considering the option of concealing data using CSS display: none. However, a few questions arise regarding the compatibility and support of CSS and display: none: Do all email ...

Is it possible to modify the default behavior of a sensitive region within a button?

I created a calculator application in React and overall, it's working fine, however... I've noticed that when I hold a click longer, it only registers as a click if the mouse was pressed down and released on the button itself. Although I unders ...

Tips for customizing the appearance of a timer using javascript and css

Check out this fiddle linked here: jsfiddle First, have a look at the initial HTML code below. For the JavaScript part, refer to the fiddle: <div id="test_time_left">Time Left :<b><span id="time_value" style="padding-left:5px;"></spa ...