基本上,我有一個html頁面,當你點擊正方形時,我已經設置了一個滑動面板。點擊它時如何讓方塊旋轉180度?我只能設置按鈕觸發div滑動或按鈕旋轉,但不能同時進行。我注意到它與我如何放置輸入標籤有關。如果它在標籤內,按鈕旋轉但對面板沒有影響。如果它在標籤外面,按下正方形將觸發側面板。一直在這一天,但似乎無法弄清楚。理想情況下,我本來希望得到替代方的箭頭,但我不知道從哪裏開始...如何獲取滑動導航面板的按鈕元素以便使用HTML和CSS進行旋轉?
-sliding格: https://codepen.io/yung_terminal/pen/oWrZZj
HTML:
<div class="main-wrap">
<input id="slide-sidebar" type="checkbox" role="button" />
<label for="slide-sidebar">
<div class="tab"></div>
</label>
<div class="content">
</div>
</div>
CSS:
.sidebar {
background-color: white;
width: 300px;
position: absolute;
top: 0;
left: 0;
bottom: 0;
}
#navpan {
position: absolute;
right: 120px;
bottom: 740px;
}
.sidebar li{
color: black;
font-weight: bold;
font-size: 25px;
text-decoration: none;
list-style: none;
}
.content {
background-color: red;
position: absolute;
top: 0;
left: 190px;
right: 0;
bottom: 0;
-moz-transition: left 0.5s ease;
transition: left 0.5s ease;
}
input[type=checkbox] {
display: none;
}
input:checked ~ .content{
left: 0;
}
input:checked ~ label {
left: 0;
}
label {
z-index: 2;
position: absolute;
top: 50%;
left: 190px;
background-color: 0;
font-size:60px;
-moz-transition: left 0.5s ease;
transition: left 0.5s ease;
}
.tab {
width: 100px;
height: 100px;
background-color: white;
transition: all 0.75s 0.25s;
transform: rotate(0);
}
#slide-sidebar:checked + .tab{
transform: rotate(180deg);
}
請附上你已經改變了什麼的說明。這將清楚說明爲什麼您的解決方案能夠正常工作,而OP則不能。 –
@JonP更新了我的答案。 :) – acmsohail
現在你應該注意到你已經介紹了OP沒有要求的兩件事情,javascript **和** jquery。如果可能的話,OP是一個CSS/HTML唯一選項。 –