Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS: styled a checkbox to look like a button, is there a hover?

I've created a small looking button to display instead of a checkbox. I was wondering if there was a way to also have a :hover look somehow? thanks

http://jsfiddle.net/zAFND/2/

like image 656
trying_hal9000 Avatar asked Oct 04 '11 00:10

trying_hal9000


People also ask

Can a checkbox be styled?

It is possible to style a checkbox using Pseudo Elements like :before, :after, hover and :checked. To style the checkbox the user first needs to hide the default checkbox which can be done by setting the value of the visibility property to hidden. Example 1: Consider the example where HTML checkbox is styled using CSS.

Can I style checkbox in CSS?

By default, browsers have their own UI style, but you can use CSS to style the checkbox and create a unique look for your website or app.

What is a button hover?

Alternatively referred to as mouseover or mouse hover, hover describes the act of moving a mouse pointer over a clickable object, but not actually clicking the left or right mouse button. For example, when you hover your mouse over any of the links on this page, they should change color, indicating they can be clicked.


2 Answers

#ck-button:hover {     background:red; } 

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

like image 146
Kelly Cook Avatar answered Oct 16 '22 04:10

Kelly Cook


it looks like you need a rule very similar to your checked rule

http://jsfiddle.net/VWBN4/3

#ck-button input:hover + span {     background-color:#191;     color:#fff; } 

and for hover and clicked state:

#ck-button input:checked:hover + span {     background-color:#c11;     color:#fff; } 

the order is important though.

like image 44
Joseph Marikle Avatar answered Oct 16 '22 05:10

Joseph Marikle