1

So I'm trying to put a hover for an image block but this time, im trying to put an image and a paragraph in the middle but still the transition is not working, have no clue why!?

This is the HTML:

        <div class="area">
          <div class="mask">
            <div class="vertical-align">
              <img src="http://placehold.it/50x50">
              <p>Play Now</p>
            </div>
          </div>
        <img src="http://placehold.it/300x300" alt="video"> 
        </div>

        <h2>Title</h2>
        <p>Paragraph</p>

      </div>

This is the CSS

.video {
    width:300px;
}

.area:hover .mask{
    display: block;
    width: 300px;
    height: 300px;
    cursor: pointer;
    transition: all 0.3s ease-in-out;
    -o-transition: all 0.3s ease-in-out;
    -ms-transition: all 0.3s ease-in-out;
    -moz-transition: all 0.3s ease-in-out;
    -webkit-transition: all 0.3s ease-in-out;
        background-color: rgba(226,23,37,0.9);
        text-align: center;}

.vertical-align{
    position: relative; 
    top: 50%; 
    transform: translateY(-50%); 
    -webkit-transform: translateY(-50%); 
    -ms-transform: translateY(-50%); 
}

.mask{
    position: absolute;
    display: none;
}

1 Answers1

1

Use opacity: 0 to opacity: 1 instead of display: none and block. you can not use transition for uncountable property.

JSFiddle

Pedram
  • 15,766
  • 10
  • 44
  • 73