V
V
Vizuality2020-04-18 11:42:46
css
Vizuality, 2020-04-18 11:42:46

How can I make the cursor act as an image mask when moving the mouse?

There are 2 pictures (A\B). Picture A is constantly visible, so that when you hover over the cursor, the area around the cursor (let's say a circle of 100x100 px) shows picture B. In graphical terms, you need to fasten the properties of the image mask to the cursor. Thank you!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
Karpion, 2020-04-18
@Karpion

It is necessary to track the movements of the mouse - and place the DIV code block containing the image at the cursor location. Approximately as when dragging the picture with the mouse - only without pressing the button.
Well, if I understood the problem correctly.

Z
zhen4ek, 2020-04-18
@zhen4ek

Can be done using jquery.
You need to hang an event on the circle to catch the hover and change the properties of the picture (for example, display)
Or do it in pure css using + or ~ (if there are other elements between the elements)

<div id="a">Div A</div>
<div id="b">Hover me</div>
<div id="c">Div B</div>

#a {
  width: 100px;
  height: 100px;
  background-color: #000;
 z-index: 1;
}
#c {
  width: 100px;
  height: 100px;
  background-color: red;
  position: absolute;
  top: 0;
  left: 0;
  z-index: 2;
  display: none;
}
#b:hover ~ #c {
    display: inline;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question