当项目悬停时显示列表

编程入门 行业动态 更新时间:2024-10-27 05:33:27
本文介绍了当项目悬停时显示列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有这个样本:

链接

.show:hover .list-categories { max-height: inherit; opacity: 1; } .list-categories { list-style-type: none; padding: 0px; margin: 0px; max-height: 0px; opacity: 0; overflow: hidden; transition: opacity 300ms ease; }

<div class="show">show div</div> <ul class="list-categories"> <li>Bed</li> <li>Bed</li> <li>Bed</li> <li>Bed</li> <li>Bed</li> <li>Bed</li> </ul>

此代码无效.我想将鼠标悬停在项目".show"上显示列表

this code does not work. I want to display the list when hover on the item ".show"

如果将开关设置为(.show:hover + .list-categories)形式,则可以使用...但是我不希望有加号.

If you put the switch in the form (.show:hover +.list-categories) it works...but I want no plus sign.

如何在不使用加号的情况下更改此代码?

How can I change this code without using the plus sign?

推荐答案

根据CSS,您可以像下面这样更改HTML.

As per your CSS you can change the HTML like BELOW.

.show:hover ul.list-categories{ max-height: inherit; opacity: 1; } .list-categories{ list-style-type: none; padding: 0px; margin: 0px; max-height: 0px; opacity: 0; overflow: hidden; transition: opacity 300ms ease; }

<div class="show">show div <ul class="list-categories"> <li>Bed</li> <li>Bed</li> <li>Bed</li> <li>Bed</li> <li>Bed</li> <li>Bed</li> </ul> </div>

更多推荐

当项目悬停时显示列表

本文发布于:2023-11-23 05:14:02,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1620214.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:项目   列表

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!