Answer the question
In order to leave comments, you need to log in
Appearing block on hover
Hi friends.
In javascript, I'm a dunce, so I'll forgive the help, I need a script so that when you hover over the image with the mouse, it is superimposed on it: background: rbga(0,0,0,.3);
And in the center of the block:
<p>Заголовок</p>
<p>Текст</p>
Answer the question
In order to leave comments, you need to log in
html structure
<div class="block-wrap">
<div class="block-img"></div>
<div class="block-text">
<h2>Заголовок</h2>
<p>Текст</p>
</div>
</div>
.block-wrap{
position: relative;
overflow: hidden;
}
.block-img{
position: relative;
width: 100%;
height: auto;
}
.block-text{
position: absolute;
top: 0;
left: 0;
background: rbga(0,0,0,.3);
color: #fff;
opacity: 0;
visibility: hidden;
width: 100%;
height: 100%;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
padding: 5%;
-webkit-transition: all 0.2s ease;
-moz-transition: all 0.2s ease;
-o-transition: all 0.2s ease;
-ms-transition: all 0.2s ease;
transition: all 0.2s ease;
}
.block-wrap:hover .block-text{
opacity: 0;
visibility: visible;
}
No css animation.
HTML layout:
<div class="cont">
<div class="overlay">
<h1>Заголовок</h1>
<p>Текст</p>
</div>
<img src="img1.jpg">
</div>
.cont {
width: 500px;
height: 500px;
position: relative;
}
.overlay {
position: absolute;
text-align: center;
width: 100%;
height: 100%;
background: rbga(0, 0, 0, 0.3);
display: none;
}
jQuery(document).on("hover", ".cont", function() {
jQuery(this).children(".overlay").fadeIn("fast");
}, function() {
jQuery(this).children(".overlay").fadeOut("fast");
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question