Want same result as code below but instead of background want hover on image
On image hover want to slide up with content
The code
h1 {
margin: 0
}
.box {
height: 200px;
width: 300px;
overflow: hidden;
border: 1px solid red;
background: #ff0;
}
.hid-box {
top: 100%;
position: relative;
transition: all .3s ease-out;
background: #428bca;
height: 100%;
}
.box:hover > .hid-box{
top: 80px;
}
<div class="box">
<!-- <img src="pic1.png"> -->
<div class="hid-box">
<h1>CSS3 slide up</h1>
<p>This is a quick demo of slide-up effect using CSS animation when hover the box. No JS required!</p>
</div>
</div>
Tried With image tag but it is not working, the image don't has fix size <div class="box">
will not work.
h1 {
margin: 0
}
.box {
height: 200px;
width: 300px;
overflow: hidden;
border: 1px solid red;
background: #ff0;
}
.hid-box {
top: 100%;
position: relative;
transition: all .3s ease-out;
background: #428bca;
height: 100%;
}
.box:hover>.hid-box {
top: 80px;
}
.box img {
position: absolute
}
<div class="box">
<img src="https://dummyimage.com/124x124/000/fff.png&text=pic1">
<div class="hid-box">
<h1>CSS3 slide up</h1>
<p>This is a quick demo of slide-up effect using CSS animation when hover the box. No JS required!</p>
</div>
</div>
Finally achived wanted result
.container {
position: absolute;
}
.image {
display: block;
}
.overlay {
position: absolute;
bottom: 0;
left: 0;
right: 0;
background-color: green;
color: white;
overflow: hidden;
width: 100%;
height: 0;
transition: .5s ease;
}
.container:hover .overlay {
height: 50%;
}
<div class="container">
<img src="https://dummyimage.com/120x120/000/fff.png&text=120x120" alt="Avatar" class="image">
<div class="overlay">
<div class="text">Hello World</div>
</div>
</div>
background
property of the box to show the image. If you want to use theimg
tag, use a class like the one of the box, make it a block level element using the display property and use :hover in the same way.