이 How can I transition height: 0; to height: auto; using CSS?을 발견했습니다.이 방법을 사용하여 button onclick의 div 높이를 변경하려고했지만 어떤 이유로 그것이 저를 위해 작동하지 않습니다. 불필요한 정보가 많이 있으면 죄송합니다.CSS 전환 가능 조절 높이
jQuery를
function playSound(soundfile){
document.getElementById("dummy").innerHTML =
"<embed src=\""+soundfile+"\" hidden=\"true\" autostart=\"true\" loop=\"false\" />";
}
$('button').bind('click', function(e) {
e.preventDefault();
$('.taller').toggleClass('animated');
});
HTML
<div id="container">
<span id="dummy"></span>
<button onclick="playSound('sound/button-30.wav','sound/button30.mp3');">PlaySound</button>
<div class="taller">I SHOULD BECOME TALLER</div>
</div>
CSS
#container{
background-color:lightblue;
width:960px;
height:550px;
}
.taller{
overflow:hidden;
background:#000;
color:#fff;
width:80px;
max-height:15px;
-webkit-transition: max-height .5s linear;
-moz-transition: max-height .5s linear;
transition: max-height .5s linear;
}
.animated{
max-height:100px;
}
네, 그게 내가 원하는 것입니다.하지만 Aptana Studio 나 내 브라우저에서 작동하지 않는 이유가 있습니다. – ocat
이것이 일어날 수있는 이유를 알고 있습니까? 그것은 jsfiddle에서 잘 작동합니다. – ocat
디버거를 firefox 또는 chrome으로 열면 콘솔에서 스크립트의 다른 부분에서 오류가 발생했는지 확인하십시오. 코드가 훌륭하게 작동 할 수 있지만 오류로 인해 코드를 작성할 수는 없습니다. – scottmgerstl