Say I have a div with the following attributes:
.box {
width: 300px;
height: 67px;
margin-bottom: 15px;
}
How would I make it so that if someone hovers their mouse over this area, it changes the background to a slightly darker colour and makes it a clickable area?
CSS Only:
To make it a 'clickable' area, you're going to want to put a
<a></a>
tag inside the div, and you may want to use jQuery to set thehref
attribute.jQuery Solution
A third solution: You could change the cursor, and also give it a click event using jQuery:
Use the above along with the following CSS:
Linking a div has worked for me simply by wrapping it in an a tag. Here is an example below with Bootstrap classes:
To change your div colour on hover add:
to your CSS :)
When you hover the background changes to the color you want and cursor becomes pointer. You can trigger an event with jQuery like so:
You can do it with CSS only:
Or with Javascript (I'm using jQuery in this example)