gpt4 book ai didi

css - 如何在div中创建下拉菜单?

转载 作者:行者123 更新时间:2023-11-28 02:36:16 24 4
gpt4 key购买 nike

如何在将指针移到文本 1x 的 div 上时显示可滚动菜单显示可滚动菜单。

我想做的是类似于下图的事情:

introducir la descripción de la imagen aquí

我的代码结构:

.spdText {
width: 3em;
height: 1.8em;
line-height: 1.8em;
position: relative;
font-size: 1em;
font-weight: 900;
text-shadow: none;
border-radius: 10%;
color: #29303b;
background-color: hsla(0,0%,100%,.9);
}


.speed {
display: none;
position: absolute;
max-height: 0;
transition: max-height 1s;
}

.speed:hover,
.btnSpd:hover .speed {
display: inline-table;
list-style: none;
max-height: 300px;
transition: max-height 1s;
top: -170px;
}
<div class="spdText">1x
<ul class="speed">
<li>x3</li>
<li>x1</li>
</ul>
</div>

最佳答案

是这样的吗?

编辑:首先,在“spdText”上方留一个空格。您将 'speed' 置于 'spdText' 之上,给它一个负的最高值。

.spdText {
width: 3em;
height: 1.8em;
line-height: 1.8em;
position: relative;
font-size: 1em;
font-weight: 900;
text-shadow: none;
border-radius: 10%;
color: #29303b;
background-color: hsla(0,0%,100%,.9);
margin-top:5rem; /* You leave a space above */
}


.speed {
display: none;
position: absolute;
max-height: 0;
transition: max-height 1s;
}

.spdText:hover .speed {
display: block;
list-style: none;
max-height: 300px;
transition: max-height 1s;
left:-25px;
background-color: black;
opacity: 0.5;
color: white;
top: -4.4rem;
}
<div class="spdText">1x
<ul class="speed">
<li>x3</li>
<li>x1</li>
</ul>
</div>

关于css - 如何在div中创建下拉菜单?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47396162/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com