这是一个非常简单的工作示例,在单击按钮时将三个 div 相互移动。HTML 代码
<div class="container">
<div class = "circlea"><h2>link</h2></div>
<div class = "circleb"><h2>link</h2></div>
<div class = "circlec"><h2>link</h2></div>
<button >click me</button>
</div>
.circlea,.circleb,.circlec{
height:150px;
width:150px;
border-radius:50%;
margin-left:50%;
margin-top:120px;
position: absolute;
transition: all 1s ease-in-out;
opacity:0;
color:white;
text-align:center;
}
.circlea{
background-color:rgba( 20, 155, 138 );
}
.circleb{
background-color:rgba( 155, 20, 144 );
}
.circlec{
background-color:rgba( 24, 155, 20);
opacity:1;
}
button{
background-color:tomato;
width:100px;
padding:10px;
color:white;
}
.transforma{
margin-left:200px;
opacity:1;
}
.transformb{
margin-left:800px;
opacity:1;
}
.transformb{
opacity:1;
}
js
$("button").click(function(){
$("div.circleb").toggleClass("transformb");
$("div.circlea").toggleClass("transforma");
});
https://codepen.io/pranjalkoshti/pen/rYNQeL