Home > Web Front-end > CSS Tutorial > How to Add Hover Effects to Custom Checkbox-Styled Buttons with CSS?

How to Add Hover Effects to Custom Checkbox-Styled Buttons with CSS?

Mary-Kate Olsen
Release: 2024-10-28 22:55:30
Original
406 people have browsed it

How to Add Hover Effects to Custom Checkbox-Styled Buttons with CSS?

Hover Effects for Custom Checkbox-Styled Buttons in CSS

When creating custom-styled checkboxes that resemble buttons, you might want to add hover effects to enhance the user experience. Here's how to achieve that using CSS:

HTML:

<code class="html"><div id="ck-button">
   <label>
      <input type="checkbox" value="1"><span>red</span>
   </label>
</div></code>
Copy after login

CSS:

<code class="css">#ck-button:hover {
    background:red;
}</code>
Copy after login

This code targets the #ck-button element using the :hover pseudo-class when the user hovers over it. The background property is then set to red, changing the button's background color on hover.

Demo:

http://jsfiddle.net/zAFND/4/

The above is the detailed content of How to Add Hover Effects to Custom Checkbox-Styled Buttons with CSS?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template