Ways to change input radio and multi-select styles with CSS3

Source: Internet
Author: User
In the development of the project, we often encounter the need to change the input radio and multi-select style, today we will introduce a simple change input and multi-select style method.

Before that, let's briefly introduce: before Pseudo-class

: Before the selector to insert content before the selected element. Use the Content property to specify what you want to insert (the contents are required).

I believe this is not difficult to understand, then we first understand the idea:

(1) First in the HTML label for the INPUT element to define the tag, that is, when you click on the label tag, the corresponding input will also be selected or canceled

(2) Next is to write the CSS, will be input hidden, just need to add your style before the label, can be a picture can also be a circle of their own, the following example is I write the circle, of course, can also be replaced by a background map.

Input[type= "Radio"]+label:before is a style that is not selected
Input[type= "Radio"]:checked+label:before is the style of the selected state

<input type= "Radio" id= "Nationality1" ><label for= "nationality1" > China </label></p>

{:;} {:;} {:;:;:;:;:;:;:;:;:;} {:;:;:;:;:;:;:;:;:;}

Replacing radio with a checkbox is more than a choice.

Note: Hiding and pseudo-class positioning are key

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.