นี่คือวิธีที่ฉันทำโดยไม่มี js
ฉันใช้ไอคอน glyphicon-triangle-right แต่ใช้ได้กับไอคอนอื่น ๆ สิ่งที่ทำคือใช้การหมุน 90 องศากับไอคอนเมื่อแผงเปิดอยู่หรือไม่ ฉันใช้Bootstrap 3.3.5สำหรับอันนี้
รหัส CSS
h4.panel-title a {
display: block;
}
h4.panel-title a.collapsed .glyphicon-triangle-right {
color: #ada9a9 !important;
transform: rotate(0deg);
}
h4.panel-title a .glyphicon-triangle-right {
color: #515e64 !important;
transform: rotate(90deg);
}
นี่คือโครงสร้าง HTML ที่นำมาจากตัวอย่าง Bootstrap
<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
<div class="panel panel-default">
<div class="panel-heading" role="tab" id="headingOne">
<h4 class="panel-title">
<a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
Proven Expertise
<span class="glyphicon glyphicon-triangle-right pull-right" aria-hidden="true"></span>
</a>
</h4>
</div>
<div id="collapseOne" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="headingOne">
<div class="panel-body">
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
</div>
</div>
</div>
</div>
.bs.collapse
ลบ ฉันเปลี่ยนด้วยshown and hidden to show and hide
เช่นกันดังนั้นภาพเคลื่อนไหวจึงเกิดขึ้นก่อนที่หีบเพลงจะเปิดขึ้น