B
B
Blackmilk42018-12-13 11:32:47
css
Blackmilk4, 2018-12-13 11:32:47

How to make a block appear on hover?

You need to do it in JQ so that when hovering a block appears, but when you remove the mouse, it also disappears ..

Answer the question

In order to leave comments, you need to log in

4 answer(s)
D
Daniel, 2018-12-13
@Blackmilk4

On pure JS:
Same thing but with jQuery:
And just in CSS:

S
SpideR-KOSS, 2018-12-13
@SpideR-KOSS

Required for JQ? Can be done with simple CSS.

.block {
 width: 100px;
 height: 100px;
 background: red;
 opacity: 0;
}

.block:hover {
 opacity: 1;
}

Or
.block {
 width: 100px;
 height: 100px;
 background: red;
 display: none;
}

.block:hover {
 display: block;
}

You can also add a fade in.
.block {
 width: 100px;
 height: 100px;
 background: red;
 opacity: 0;
}

.block:hover {
 opacity: 1;
 transition: .3s;
}

A
Anton, 2018-12-13
@Eridani

https://jsfiddle.net/502ek6ta/

A
arasome, 2018-12-13
@arasome

It is possible without js.
If you need to show the inner block:

.block .block-child {
 opacity: 0;
}

.block:hover .block-child  {
 opacity: 1;
 transition:  opacity .3s;
}

If you need to show the adjacent block:
.block+.block-child {
 opacity: 0;
}

.block:hover+.block-child  {
 opacity: 1;
 transition:  opacity .3s;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question