当您单击相应的标题时,我希望旋转一个V形符号。截至目前,所有的V形旋转。我想我必须指定哪个雪佛龙,但不知道如何。我在ASP.NET MVC 5中工作,我正在使用razor视图通过列表进行预测。
索引
@{
foreach (var item in Model)
{
<div class="accordion">
<a href="#"><h4>@item.Title</h4><i class="fa fa-chevron-right rotate"></i></a>
</div>
<div class="accordion-desc">
<h3>@Resource.AccordionProjectLead</h3>
<h4>Kay Wiberg</h4>
<h3>@Resource.AccordionDescription</h3>
<p>
@item.Description
<p>
<div class ="link">
<a href="@item.Url">@Resource.AccordionGoTo</a>
</div>
</div>
}
}
旋转雪佛龙的CSS
.rotate {
-moz-transition: all 0.1s linear;
-webkit-transition: all 0.1s linear;
transition: all 0.1s linear;
}
.rotate.down {
-moz-transform: rotate(90deg);
-webkit-transform: rotate(90deg);
transform: rotate(90deg);
}
手风琴和雪佛龙的JS
$(document).ready(function() {
$(".accordion-desc").fadeOut(0);
$(".accordion").click(function() {
$(".accordion-desc").not($(this).next()).slideUp('fast');
$(this).next().slideToggle(400);
});
});
$(".accordion").click(function() {
$(".rotate").toggleClass("down");
});
来自浏览器:
<div class="container">
<div class="accordion">
<a href="#">
<h4>Test Site</h4><i class="fa fa-chevron-right rotate down"></i></a>
</div>
<div class="accordion-desc" style="display: none;">
<h3>Projektledare</h3>
<h4>Kay Wiberg</h4>
<h3>Beskrivning</h3>
<p>
</p>
<div class="link">
<a href="">Gå till</a>
</div>
</div>
<div class="accordion">
<a href="#">
<h4>Test site 2</h4><i class="fa fa-chevron-right rotate"></i></a>
</div>
<div class="accordion-desc" style="display: none;">
<h3>Projektledare</h3>
<h4>Kay Wiberg</h4>
<h3>Beskrivning</h3>
<p>
Somthindsyvgds
</p>
<div class="link">
<a href="">Gå till</a>
</div>
</div>
</div>
答案 0 :(得分:1)
$(document).ready(function() {
$(".accordion-desc").fadeOut(0);
$(".accordion").click(function() {
$(".accordion-desc").not($(this).next()).slideUp('fast');
$(this).next().slideToggle(400);
});
});
$(".accordion").click(function() {
$(".accordion").not(this).find(".rotate").removeClass("down");
$(this).find(".rotate").toggleClass("down");
});
.rotate {
-moz-transition: all 0.1s linear;
-webkit-transition: all 0.1s linear;
transition: all 0.1s linear;
}
.rotate.down {
-moz-transform: rotate(90deg);
-webkit-transform: rotate(90deg);
transform: rotate(90deg);
}
.accordion {
background: blue;
}
.fa, h4 {
color: white;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<div class="container">
<div class="accordion">
<a href="#">
<h4>Test Site</h4><i class="fa fa-chevron-right rotate down"></i></a>
</div>
<div class="accordion-desc" style="display: none;">
<h3>Projektledare</h3>
<h4>Kay Wiberg</h4>
<h3>Beskrivning</h3>
<p>
</p>
<div class="link">
<a href="">Gå till</a>
</div>
</div>
<div class="accordion">
<a href="#">
<h4>Test site 2</h4><i class="fa fa-chevron-right rotate"></i></a>
</div>
<div class="accordion-desc" style="display: none;">
<h3>Projektledare</h3>
<h4>Kay Wiberg</h4>
<h3>Beskrivning</h3>
<p>
Somthindsyvgds
</p>
<div class="link">
<a href="">Gå till</a>
</div>
</div>
</div>