How to give css style to Radio button

2020-01-19 04:34发布

问题:

how to give css style to Radio button, and should work on Mac, safari and Chrome too

  <form action="">
  <input type="radio" name="gender" value="male"> Male<br>
  <input type="radio" name="gender" value="female"> Female<br>
  <input type="radio" name="gender" value="other"> Other
  </form>

回答1:

You could write this into your CSS-File.

input[type="radio"] {
    ... your declarations here ...
}

This is the selector for your radios.


NOTE: This will affect other radios on your site too. It would be better if you wrap your radios with a div or other tags and give the tag a specific id. Then you could select the radios inside the id like this:

#yourDivId input[type="radio"] {
    ... your declarations here ...
}


标签: html css sass