1
我正在使用AngularJS手風琴。當我使用多個手風琴狀手風琴1,手風琴-2,手風琴3,我點擊第一個手風琴,手風琴打開,如果我點擊第二個手風琴,第2折皺也打開。 我的問題是:如何確保當我打開第一個手風琴時,其他手風琴再次關閉?如何在AngularJS中打開另一個手風琴時關閉AngularJS手風琴
這裏是我的代碼
<div>
<button class="accordion"><b>Mens</b>
</button>
<div class="panel">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
</div>
<button class="accordion"><b>Womens</b>
</button>
<div class="panel">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
</div>
<button class="accordion"><b>Kids</b>
</button>
<div class="panel">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
</div>
</div>
這裏是我的CSS樣式
button.accordion {
background-color: #e6e6e6;
color: #444;
cursor: pointer;
padding: 11px;
width: 100%;
border: none;
text-align: left;
outline: none;
font-size: 12px;
transition: 0.4s;
border-left: 5px solid #4d4dff;
}
button.accordion.active,
button.accordion:hover {
background-color: #d9d9d9;
}
div.panel {
padding: 0 18px;
background-color: #f2f2f2;
max-height: 0;
overflow: hidden;
transition: 0.6s ease-in-out;
opacity: 0;
margin-bottom: 8px;
}
div.panel.show {
opacity: 1;
max-height: 500px;
}