0

.postdivにカーソルを合わせたときにのみpost-footerが表示されるようする必要があります。どうやってやるの?post-footer divには、リンク(タグ)のみが含まれます。

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

2 に答える 2

2

次のような構造で:

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

次のようなものを使用する必要があります。

.post-footer { display:none; }

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

または、滑らかに見せたい場合は、次のトランジションを使用できます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 */ }

注:トランジションのブラウザ互換性テーブル

両方の方法のデモ:http://dabblet.com/gist/2819975

于 2012-05-28T15:59:16.587 に答える
1

jqueryをダウンロードして、htmlに含めます。

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

上記をjavascriptファイルで試してください

于 2012-05-28T16:00:01.030 に答える