Gao fushuai usage of input radio and checkbox labels

Source: Internet
Author: User

The native effects of the radio and checkbox tags in the input tag are too ugly.

Fortunately, the WebKit browser can now use

-webkit-appearance:none;

To change your image.

Radio tag

Scenario 1: A dot below many images. The advantage of this is that you only need to set the checked of this element to true if you set a dot in JS, you do not need to write JS scripts when you click them with the mouse.

The simple CSS code is as follows:

.radio{    width: 10px;    height: 10px;    -webkit-appearance: none;    pointer-events: none;    border-radius: 5px;    display: inline-block;    background-color: rgb(205,205,205);    margin: 0 5px;}.radio:checked{    background-color: rgb(134,176,213);}
Checkbox tag

Scenario 1: The toggle button can use an image and set its background-position-x attribute to move left and right.

The simple CSS code is as follows:

.checkbox{    -webkit-appearance:none;    width: 100px;height: 30px;    background-color: #fff;    background-image: url(‘img/checkbox.png‘);    background-repeat: no-repeat;}.checkbox:checked{    background-position-x: 100px;}
Conclusion

Of course, this is only the simplest effect. You can also add various effects, such as mouse strokes, mouse clicks, and animations.

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.