Lukas Zerger
Lukas Zerger

Reputation: 31

CSS mouse cursor over text in div

I want to change the mouse cursor over the text in a certain div. If I use:

.divchange { cursor: pointer;}

the cursor will change over the whole div and not just over the text.

Upvotes: 1

Views: 18730

Answers (2)

Anmol Sandal
Anmol Sandal

Reputation: 1488

You can place a text in span or you can add hover to the certain text.

Using Hover

.text p:hover {cursor: pointer;}
<div class="text">
  <p>Hello</p>
</div>

Or just adding style to that element where you want cursor to be a pointer

.text p{cursor: pointer;}
<div class="text">
  <p>Hello</p>
</div>

Upvotes: 3

kyun
kyun

Reputation: 10264

.divchange { 
  display: inline-block;
  cursor: pointer;

}
<div style="background:gray">
  <div class="divchange">text only</div>
</div>

The point is display:inline-block.

Upvotes: 3

Related Questions