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
Mary-Kate OlsenOriginal
2024-10-28 22:55:30413browse

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>

CSS:

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

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!

Statement:
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