0

I have an image and when you put your mouse over it I have another div that shows. I am trying to get it to fade in and out slower but everything I have tried so far has not worked. Any help would be greatly appreciated. Thanks

.image {
background-position: center;
background-repeat: no-repeat;
background-size: cover;
height: 100%;
width: 100%;  
}

.overlay {
display: none;
}

.image:hover .overlay { 
box-sizing: border-box; 
display: block; 
height: 100%; 
left: 0; 
-moz-box-sizing: border-box; 
position: absolute;
top: 0;
-webkit-box-sizing: border-box;
width: 100%;   
}

2 Answers2

0

Set the overlay opacity to 0, then 1 on hover, and add a transition rule:

html, body{
   height: 100%;
   margin: 0;
}

.overlay{
   opacity: 0;
   transition: opacity .6s ease-in;
   height: 100%;
}

.overlay:hover{
   opacity: 1;
}
<div class="overlay">
  <ul>
    <li>facebook</li>
    <li>amazon</li>
  </ul>
</div>
symlink
  • 11,984
  • 7
  • 29
  • 50
0

You need an transition and opacity:

.image {
background-position: center;
background-repeat: no-repeat;
background-size: cover;
height: 100%;
width: 100%;  
}

.overlay {
opacity: 0;
transition: 200ms;
}

.image:hover .overlay { 
box-sizing: border-box; 
display: block; 
height: 100%; 
opacity: 1;
left: 0; 
-moz-box-sizing: border-box; 
position: absolute;
top: 0;
-webkit-box-sizing: border-box;
width: 100%;   
}

   
bill.gates
  • 14,145
  • 3
  • 19
  • 47