user1679941
user1679941

Reputation:

How can I make a DIV cursor and background color change if I hover over it?

I have this HTML code:

<div class="authTabs">
   <div class="h2">Login</div>
   <div class="h2">Register</div>
</div>

I am using CSS. Can someone tell me how I can make it so that my cursor changes to a finger pointing and my background color changes when the Login or Register DIVs are hovered over?

Upvotes: 3

Views: 10423

Answers (5)

Mad Angle
Mad Angle

Reputation: 2330

<style>
.h2{
  backgorund-color : black;
cursor: pointer
}
.h2:hover{
  backgorund-color : blue;
cursor: pointer
}
</style>

Upvotes: 1

Manwal
Manwal

Reputation: 23816

See DEMO

.authTabs {
 cursor: pointer;
}

.h2:hover {
background-color: red;
}

Upvotes: 5

Martin Sonesson
Martin Sonesson

Reputation: 789

h2:hover{
  cursor: pointer;
  background-color: red;
}

Upvotes: 0

link64
link64

Reputation: 1976

Add this to your css definitions:

.h2:hover {
   cursor: pointer;
    background-color: red;
 }

Upvotes: 1

Gibbs
Gibbs

Reputation: 22964

.clsName:hover
{
  cursor: pointer;
  background-color: red; // required color
}

.authTabs div:nth-of-type(1)
{
 cursor: pointer;
  background-color: red; // required color
} 

.authTabs div:nth-of-type(1)
{
  cursor: pointer;
  background-color: red; // required color
}

Upvotes: 0

Related Questions