我想旋转图标正确点击相应的图标
I want to spin the icons correctly on click on corresponding icon
在这个html代码中,我试图旋转一个图标180度点击相应的图标,并返回当点击其他图标或外部。这里的问题是,第一个图标不返回当点击第二个和第二个是不返回点击第一个图标或点击外面。如何解决这个问题?
function rotate(e){
document.getElementById("me").className="spinner in fa fa-caret-down";
e.stopPropagation();
}
function resetRotation(){
document.getElementById("me").className="spinner out fa fa-caret-down";
}
document.addEventListener('click', resetRotation);
function rotatea(e){
document.getElementById("you").className="spinner in fa fa-caret-down";
e.stopPropagation();
}
.spinner {
transition: all 0.5s linear;
}
.spinner.in{
transform: rotate(180deg);
}
.spinner.out{
transform: rotate(0deg);
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css">
<i onclick="rotate(event)" id="me" class="spinner fa fa-caret-down "></i>
<i onclick="rotatea(event)" id="you" class="spinner fa fa-caret-down"></i>
function rotate(e){
resetRotation();
document.getElementById("me").className="spinner in fa fa-caret-down";
e.stopPropagation();
}
function resetRotation(){
document.getElementById("me").className="spinner out fa fa-caret-down";
document.getElementById("you").className="spinner out fa fa-caret-down";
}
function rotatea(e){
resetRotation();
document.getElementById("you").className="spinner in fa fa-caret-down";
e.stopPropagation();
}
document.addEventListener('click', resetRotation);
.spinner {
transition: all 0.5s linear;
}
.spinner.in{
transform: rotate(180deg);
}
.spinner.out{
transform: rotate(0deg);
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css">
<i onclick="rotate(event)" id="me" class="spinner fa fa-caret-down "></i>
<i onclick="rotatea(event)" id="you" class="spinner fa fa-caret-down"></i>
相关文章:
- CSS 图标旋转 鼠标关闭时的第二个动画
- jQuery:旋转加号到减号字体的真棒图标,在手风琴部分点击
- Fabric js自定义旋转图标仅在iphone'谷歌chrome浏览器
- 悬停时旋转一个字体很棒的图标
- 单击时旋转字体真棒图标
- 如何开始旋转一个引导程序字体真棒图标,然后用jQuery停止它
- openlayers围绕图标旋转
- Javascript加载/旋转图像/图标,同时加载搜索结果
- 加载记录时旋转图标冻结
- 有问题旋转facebook, twitter和youtube图标图像
- 同时旋转图标和切换内容
- 将图标/文本放置在旋转图像上
- 我想旋转图标正确点击相应的图标
- 我想让图标旋转回来时,点击外面
- 改变所有图标向下旋转为一个
- 如何更改fabricjs中的旋转图标
- 我该如何打开我的手风琴&字形图标在单击时旋转,在重新单击时反转
- 如何创建一个在单击时向下旋转的图标
- 使用字体真棒图标并删除图标微调图标旋转
- 如何使每个手风琴菜单上的雪佛龙图标旋转