我想展開和降低標題的高度,當我點擊div「箭頭」。我試圖用jQuery來addClass,但它並沒有真正的工作 HTML:(jquery)點擊div展開css轉換
<header>
<p>The title..</p>
<h1>Some text</h1>
<div class="arrow" id="arrow">
<img src="img/arrow.svg" />
</div>
</header>
CSS
header {
background: #2282A4;
color: #fff;
text-align: center;
width: 100%;
height: 450px;
transition: height 0.5 ease;
}
expandheight {
height: 850px;
}
JQuery的:
$(document).ready(function() {
$(function() {
$('#arrow').click(function() {
$('header').addClass('expandheight');
});
});
});
我不知道我是怎麼現在可以使用相同的按鈕降低高度,當它處於活動狀態時刪除「expandheight」類並在不是時添加它......我試過如果/其他,我失敗了。
加「像素」到你的CSS類 –
我寫錯在這裏,在我的代碼指定850像素...... – ShadowXsc
請補充。 (點)上課前(css) –