Customizing the appearance of radio buttons goes beyond their basic functionality. To modify their styling, including both the shape and the indicator dot, CSS offers several possibilities.
One solution is to use the :after pseudo-class to overlay a custom style on top of the radio button input. By carefully defining the size, position, shape, and colors, developers can create personalized radio buttons.
For instance, the following CSS code modifies the appearance of radio buttons:
input[type='radio']:after { width: 15px; height: 15px; border-radius: 15px; top: -2px; left: -1px; position: relative; background-color: #d1d3d1; content: ''; display: inline-block; visibility: visible; border: 2px solid white; } input[type='radio']:checked:after { width: 15px; height: 15px; border-radius: 15px; top: -2px; left: -1px; position: relative; background-color: #ffa500; content: ''; display: inline-block; visibility: visible; border: 2px solid white; }
Using this code, you can easily apply different colors and shapes to both the radio button shape and the indicator dot, giving your form controls a more refined and customized look.
The above is the detailed content of How Can I Style Radio Buttons with CSS?. For more information, please follow other related articles on the PHP Chinese website!