我感興趣的是CSS(不需要JavaScript)的方式炫耀div
或一個你:hover
以外的元素,像這樣:隱藏懸停兄弟DIV與CSS僅
#divid {
display: none;
}
a:hover #divid {
display: block;
}
<a href="#">Hover me!</a>
<div id="divid">Hello there, fellow friend!</div>
我很好奇,因爲我想在鼠標懸停某個菜單元素的時候創建一個東西,您將會在瀏覽器的左邊緣找到搜索欄(它會是position: fixed;
)。
編輯:
上面的代碼實際上並沒有whatI想要的,我想。
這是實際的代碼,因爲它無法解決答案。
#fixed2 a:hover + .nav {
background: black;
}
#options:hover + #search_text {
position: fixed;
top: 0;
left: 0;
}
<ul class="nav">
<li id="left" class="big">
<a href="#">
<img width="35px" src="square.png" />
</a>
</li>
<li id="left" class="arrow">
<a href="#">
<img src="arrow.png" />
</a>
</li>
<li id="left">
<a href="#">
<img width="17px" style="margin-left: -7px" src="refresh.png" />
</a>
</li>
<li id="left">
<a href="#">
<img width="18px" style="opacity: 0.94; margin-top: -1px;" src="help.png" />
</a>
</li>
<div id="fixed">
<li id="search">
<form action="" method="get">
<input type="text" name="search_text" id="search_text" placeholder="Search" />
<input type="button" name="search_button" id="search_button">
</form>
</li>
</div>
<div id="fixed2">
<li class="icn" id="options">
<a href="#">
<img width="25px" src="settings.png" />
</a>
</li>
</div>
</ul>
爲什麼它不正常工作,只是實際工作?
這僅僅是一個例子。我將編輯代碼。它可以通過任何你想要的元素,只要它有一個合適的class/id。 – Michal
好的,我可以問你實際的代碼嗎,因爲我真的不明白。 –
@AlexVasile看看我的答案,它有你的代碼 – dippas