我创建了一个带有Bootstrap的手风琴链接,我想在手风琴关闭时有一个“Plus”标志,在arcordon打开时有一个标识“Less”。这是我的HTML代码:
<div class="panel-group" id="accordion">
<div class="panel panel-default">
<div class="panel-heading">
<a data-toggle="collapse" data-parent="#accordion" href="#collapse1">
<h4 class="panel-title">
<i class="fa fa-object-group fa-lg"></i> Ses contenus <span class="badge">12</span>
<div class="panel-button"><i class="fa fa-minus-circle fa-lg"></i></div>
</h4>
</a>
</div>
<div id="collapse1" class="panel-collapse collapse">
<div class="panel-body"><dd>{{ drupal_view('profil_page_contenu_utilisateur', 'block_1') }}</dd></div>
</div>
</div>
</div>
这是css,但它不起作用:
body.path-profile .field--name-dynamic-block-fieldprofile-profil-page-contenu-utilisateur .panel-button div.collapse > a i:before {
content: '\f055';
}
body.path-profile .field--name-dynamic-block-fieldprofile-profil-page-contenu-utilisateur .panel-button div.collapse > a[aria-expanded=true] i:before {
content: '\f056';
}
希望这可以帮助...
$(document).ready(function(){
$("#collapse1").on("hide.bs.collapse", function(){
$("#icon").html('<span class="glyphicon glyphicon-plus"></span>');
});
$("#collapse1").on("show.bs.collapse", function(){
$("#icon").html('<span class="glyphicon glyphicon-minus"></span>');
});
});
#icon{
float: right;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<h2>Collapsible Panel</h2>
<p>Click on the collapsible panel to open and close it.</p>
<div class="panel-group">
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" href="#collapse1">Collapsible panel<p id="icon"><span class="glyphicon glyphicon-plus"></p></a>
</h4>
</div>
<div id="collapse1" class="panel-collapse collapse">
<div class="panel-body">Panel Body</div>
<div class="panel-footer">Panel Footer</div>
</div>
</div>
</div>
</div>
</body>
</html>