0
當我的鼠標位於顯示的div(.menu)上時,如何讓按鈕保持懸停(背景:紅色)?將鼠標懸停在按鈕上會顯示div。在顯示的div上如何讓按鈕保持盤旋?
https://jsfiddle.net/on5Lfmoo/
HTML
<button class="logo">
a
</button>
<div class="menu">
aaa
</div>
CSS
.menu {
transform: translateX(-250px);
width: 240px;
color: white;
background: rgba(10,10,10,0.2);
height: 100%;
position: absolute;
transition: linear 0.5s;
}
.logo:hover {
background: red;
}
.logo:hover + .menu, .menu:hover {
transform: translateX(0px);
}
您將需要使用JavaScript –
這最好用jQuery來實現。即使是一個簡單的'toggleClass'函數在這裏也能很好地爲您服務。 – Frits
感謝您的意見:) – halp