這裏很簡單在點擊按鈕時移動三個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
理想的解決方案取決於div層的HTML,用於覆蓋該div的HTML,如果包裝有一個,當然還有一些重要的CSS讓他們在默認狀態下。因爲理想的解決方案可能像'[overlay div] .style.position =「absolute」'一樣簡單。 – 2017-10-29 10:51:49