gpt4 book ai didi

javascript - Jquery toggle div with arrow animation fontawesome css

转载 作者:太空宇宙 更新时间:2023-11-03 22:25:43 25 4
gpt4 key购买 nike

我有一个包含很多 DIVS 的过滤器菜单。都具有相同的类:

<div class="filter-groep">
<h3 class="filter-title">Filter Title
<div class="tooltip-info">
<div class="tooltip-info-container">
Some tooltip information
</div>
</div>
</h3>
<div class="filter-content">
Filter content
</div>
</div>

我尝试了很多不同的方法,但大多数都不是我想要的。

我尝试了这篇文章的 JSfiddle: Toggle up and down arrows in a simple accordion widget

http://jsfiddle.net/nandhakumarsri9/gu7h3/8/

但这是一个 Accordion ,所以一个 div 在另一个打开时关闭。我想分别打开和关闭它们,我希望箭头在打开和关闭时显示动画。

箭头也是用一些奇怪的边框 CSS 完成的,我知道你可以用 CSS 和 FontAwesome 图标来完成。

以前有人做过吗?

最佳答案

编辑 修复了一些错误,新版本在这里https://jsfiddle.net/mhL3yken/57/

看看这个片段。希望对您有所帮助!

$(".filter-groep").on('click', function(){
var $filterContent = $(this).children(".filter-content");
var $arrow = $(this).find(".fa-caret-down");

if(!$filterContent.hasClass("opened")){
$filterContent.addClass("opened").slideDown(200);
$arrow.addClass("rotated");
} else if($filterContent.hasClass("opened")){
$filterContent.removeClass("opened").slideUp(200);
$arrow.removeClass("rotated");
}
});
* {
box-sizing: border-box;
}

body {
font-family: sans-serif;
margin: 0;
}

.filter-groep {
width: 300px;
cursor: pointer;
}
.filter-groep .filter-title {
width: 100%;
background-color: #3276e5;
border-bottom: 2px solid #2861bf;
color: #fff;
padding: 20px;
margin: 0;
}
.filter-groep .filter-title .tooltip-info {
font-size: 12px;
}
.filter-groep .filter-content {
display: none;
width: 100%;
background-color: #ededed;
padding: 10px 20px;
font-size: 14px;
}

.fas {
transition: transform 200ms ease-in-out;
}

.rotated {
transform: rotate(180deg);
transition: transform 200ms ease-in-out;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<head>
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.1.0/css/all.css" integrity="sha384-lKuwvrZot6UHsBSfcMvOkWwlCMgc0TaWr+30HWe3a4ltaBwTZhyTEggF5tJv8tbt" crossorigin="anonymous">
</head>

<div class="filter-groep">
<h3 class="filter-title">
<i class="fas fa-caret-down"></i>
Filter Title
<div class="tooltip-info">
<div class="tooltip-info-container">
Some tooltip information
</div>
</div>
</h3>
<div class="filter-content">
Filter content
</div>
</div>
<div class="filter-groep">
<h3 class="filter-title">
<i class="fas fa-caret-down"></i>
Filter Title
<div class="tooltip-info">
<div class="tooltip-info-container">
Some tooltip information
</div>
</div>
</h3>
<div class="filter-content">
Filter content
</div>
</div>
<div class="filter-groep">
<h3 class="filter-title">
<i class="fas fa-caret-down"></i>
Filter Title
<div class="tooltip-info">
<div class="tooltip-info-container">
Some tooltip information
</div>
</div>
</h3>
<div class="filter-content">
Filter content
</div>
</div>

关于javascript - Jquery toggle div with arrow animation fontawesome css,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51306410/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com