Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
249 views
in Technique[技术] by (71.8m points)

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%;
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...