Putting css borders around radio buttons

前端 未结 7 1932
遥遥无期
遥遥无期 2020-12-01 14:37

I\'m trying to get a garish red border around some radio buttons, but it is not showing up in Firefox latest or Chrome latest. Work fine in IE9/IE8.

Each of the inp

7条回答
  •  攒了一身酷
    2020-12-01 15:13

    I know this is four years old, but I came up with a nice solution using CSS Pseudo elements.

    My requirement was to highlight an unchecked checkbox, or radio button in validation.

    
    
    /* Radio button and Checkbox .required needs an after to show */
    input[type=radio].required::after, input[type=checkbox].required::after {
        display: block;
        width: 100%;
        height: 100%;
        background: transparent;
        content: '';
        border: 2px solid red !important;
        box-sizing: border-box;
    }
    /* Radio buttons are round, so add 100% border radius. */
    input[type=radio].required::after {
         border-radius:100%;
    }
    

提交回复
热议问题