我試圖在使用LESS懸停時更改我的導航菜單中的文本。 我跟着this solution,但它不適合我,我不明白爲什麼。使用LESS更改懸停上的文本不起作用
這裏是我的html:
<nav class="sideNav">
<ul>
<li><a href=""><span>one</span></a></li>
<li><a href=""><span>2</span></a></li>
<li><a href=""><span>3</span></a></li>
<li><a href=""><span>4</span></a></li>
<li><a href=""><span>5</span></a></li>
</ul>
</nav>
和我LESS:
li:nth-child(2) span{
position: relative;
content: '2';
}
li:nth-child(2):hover li:nth-child(2) span{
display: none;
}
li:nth-child(2):hover li:nth-child(2):after{
content: 'ADD';
}
任何幫助,將不勝感激,謝謝。
你不能選擇在CSS中,使用第二個元素的第1個要素'content'只能用僞元素的作品。順便說一句你的代碼是香草CSS,而不是。我建議你尋找JS解決方案。 –
那也不是很少?這是CSS。 – Aaron
這是一個錯字。固定。 – Jake