html - CSS如何把下拉菜单改为上拉菜单?

查看:1501
本文介绍了html - CSS如何把下拉菜单改为上拉菜单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问 题

<html>
<head>
  <style>
        .dplayer-resolution-box {
            display: none;
        }

        .dplayer-resolution:hover .dplayer-resolution-box {
            display: block;
        }
        
        .dplayer-resolution {
            margin-top: 200px;
        }
    </style>
</head>

<body>
<div class="dplayer-resolution">
    <p>最近</p>
    <div class="dplayer-resolution-box">
        <div class="dplayer-resolution-item">时间最近</div>
        <div class="dplayer-resolution-item">评论最多</div>
        <div class="dplayer-resolution-item">被赞最多</div>
    </div>
</div>
</body>

</html>

我的代码结构基本如上,现在是hover时显示下拉菜单,请问怎么实现上拉菜单呢?我试着添加下面的代码,结果还是不行

.dplayer-resolution:hover .dplayer-resolution-box {
    display: block;
    position:absolute;
    bottom: 100%;
}

解决方案

还要为.dplayer-resolution添加position: relative;

这篇关于html - CSS如何把下拉菜单改为上拉菜单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆