0

I need the post-footer to be visible only when hovering the .post div. How can I do that? The post-footer div only contains links(tags).

<div class="post"> 
  <!-- other divs --> 
  <div class="post-footer"><!-- footer content here -->
  </div> 
</div>
Ciprian
  • 25
  • 6

2 Answers2

2

With a structure like:

<div class="post">
    <!-- other divs -->
    <div class="post-footer"><!-- footer content here --></div>
</div>

You need to use something like:

.post-footer { display:none; }

.post:hover .post-footer { display: block; }

Alternatively, if you want to make it look smooth, you could use transitions on max-height:

.post-footer { max-height: 0; transition: max-height 1s linear; }

.post:hover .post-footer { max-height: 300px; /* some value that will always be larger than the height of your footer */ }

Note: browser compatibility table for transitions

Demo for both methods: http://dabblet.com/gist/2819975

Ana
  • 35,599
  • 6
  • 80
  • 131
1

Download jquery and include it into your html;

$(document).ready(function(){
    $('.post').hover(function(){
        $(this).find('.post-footer').toggle(true);
    },function(){
        $(this).find('.post-footer').toggle(false);
    });
});

try the above in a javascript file

DickieBoy
  • 4,886
  • 1
  • 28
  • 47