This time to bring you the CSS Set checkbox check box style, CSS set checkbox check box style of attention to what, the following is the actual case, take a look.
First, you need to add a section of CSS to hide all checkbox checkboxes, and we'll change the look. To do this, you need to add a piece of code to your CSS file.
After hiding all of the checkbox checkboxes, we need to add a label HTML element, and we all know that when clicked on a label label with the For property, the checkbox for the checkbox is selected. This means that we can use the label's click event to process our checkbox check box.
Style One
This check box style is like an unlock slider, and the sliders are checked and unchecked to show different positions. When you click the Slider button (label label), the check box is selected, and then the slider moves to the on position.
We start creating the HTML for the check box area.
Because this style check box, a label is not enough to complete the task, we use a P element to include a checkbox, we need to use them for black bands and fillets.
Now we can put the label as a slider on the stripe, we want the button effect to move from one side of the strip to the other, and we can add a label transition.
Now that the slider is in the selected (closed) position, when we select the check box, we want a reaction to occur, so we can move the slider to the other end. We need to know that the Judge check box is selected and if so, the left property of the label element is changed.
This is the CSS for the first checkbox you need.
Style Two
This check box is styled like a style, but unlike this, the slider button changes color. When you click the slider button, it moves to the other side of the strip and changes the color of the button.
The HTML code and style one are exactly the same.
This p becomes a bit larger than the style, and the label remains as a slider, using the CSS below to define it.
There is a black bar in the middle of the pattern, and the slider slides around it, but the P element is already in use, so we need to create a new element with: before Pseudo-class.
As with style one, next we write a CSS style for the label and use it as a slider.
I want to implement the same selection as the style, change the left and background properties of the label when it is selected.
Style three
The check box style is more complex than the style two, it slides right and left as in the previous example, and when you change the selected and unchecked states, the slider slides to the other side and displays the corresponding text in the original position.
First, we write the HTML code, which is the same as before.
Then we use P as the slider in the same way, and the following code creates a strip of black fillet, and we can put the slider and the text inside.
When the slider is unchecked, the slider is on the left and "OFF" appears on the right, and when clicked, the slider moves to the right and "on" appears on the left.
But the number of elements is not enough to allow us to implement these functions, so we will use: Before and: After two pseudo-classes to create two elements, respectively, put "on" and "OFF".
As before, let's add the slider style, which moves to the other side when clicked, and changes the color.
Style Four
In this style, we create two circles that change the color of the circle inside when clicked to indicate the selected and unchecked state.
The same HTML code as before.
Next we create the outer circle for the checkbox, use the CSS's Border-radius property, and set it to 100% to create a positive circle.
We then use the LABEL element to create a smaller circle, which changes color according to the checkbox state.
style Five
This check box has a different style, it looks just a little bit better than the default checkbox style of the browser, but the difference is that we can define its style according to our own needs.
First, it's the same HTML code.
In the previous example, we used p as the slider band or the outer circle of the checkbox, but this time we don't need to use the P element to set the area of the check box.
The label label is used for the Click event and the box style for the check boxes we want to define.
Next, we'll create a tick in the box, for which we can create a new element using the after pseudo-class, and to implement this style, we can create a 5px x 9px rectangle and give him a border. When we remove the top and right border, it will look like a letter L. Then we can use the CSS's Transform property to rotate it so that it looks like a tick.
In the above CSS, we have set its transparency to 0.2, so you will see a check box with a translucent checkmark. You can deepen a little while hovering, and when selected, you can set it to opaque.
This will create a new checkbox style for you.
Believe that you have read the case of this article you have mastered the method, more exciting please pay attention to the PHP Chinese network other related articles!
Recommended reading:
CSS selector use of the detailed
Specific tips for using CSS margin