divのコンテンツを他のdivの画像をクリックして表示します。私は基本的なアイデアが働いているが、divにコンテンツを入れると、divが閉じられたときに非表示になることはありません。jsとcssを使用してdiv内のコンテンツを隠す/公開する
<ul>
を入力し、<ul>
はdivが非表示の場合でも常に表示されます。
$(document).ready(function() {
$('#header').click(function() {
$('#content').removeClass('hidden');
$('#content').addClass('visible');
});
$('#content').on('mouseleave', function (e) {
setTimeout(function() {
$('#content').removeClass('visible').addClass('hidden');
}, 600);
});
});
.hidden{
max-height: 0px;
}
.visible{
max-height: 500px;
}
#content{
width:200px;
height:200px;
background:teal;
-webkit-transition: max-height 0.8s;
-moz-transition: max-height 0.8s;
transition: max-height 0.8s;
}
#header{
width:10px;
height:10px;
background:darkred;
margin:10px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="header"></div>
<div id="content">
<ul>
<li>some text</li>
<li>some text</li>
</ul>
</div>
は'オーバーフローを追加しますか? – z0mBi3