html - ELEMENTOR 中的 CSS 和 HTML 用于 1 框标题下拉菜单
问题描述
我想让我的标题在悬停在它上面时放在一个“盒子”中。就像在这个网站上一样:https ://www.dasbootshaus.at/de/das-bootshaus.html当您将鼠标悬停在它上面时,它会立即在整个下拉列表中消失。我尝试在 elementor 中作为自定义 html 和 css 执行此操作,我的代码如下所示:
HTML:
<div class="dropdown">
<button class="dropbtn">ÜBER UNS</button>
<div class="dropdown-content">
<a href="#">GALERIE</a>
<a href="#">LAGE</a>
</div>
</div>
CSS:
.full_center_dropdown nav ul {
min-width: 100% !important;
}
.full_center_dropdown nav ul a {
justify-content: center;
}
/* Show the dropdown menu on hover */
.dropdown:hover .dropdown-content {display: block;
}
/* Dropdown Button */
.dropbtn {
position: relative;
background: transparent;
color: white;
padding: 20px;
width: 150px;
font-size: 15px;
border: none;
text-align: center;
font-weight: 900;
font-family: LATO;
transition: ease-in-out 0.8s;
margin-left: 20px;
}
.dropdown:hover .dropbtn {
background: white;
transition: background ease-in-out 0.5s;
color: black;
}
/* The container <div> - needed to position the dropdown content */
.dropdown {
position: relative;
display: inline-block;
}
/* Dropdown Content (Hidden by Default) */
.dropdown-content {
position: absolute;
padding: 5px;
width: 150px;
left:-999em;
margin-left: 20px;
}
.dropdown:hover .dropdown-content {
background-color:white;
transition: background ease-in-out 0.5s;;
}
.dropdown:hover .dropdown-content {display: block;}
/* Links inside the dropdown */
.dropdown-content a {
color: black;
padding: 12px 16px;
font-size: 15px;
text-decoration: none;
display: block;
text-align: center;
}
我尝试了不同的不透明和缓入淡出过渡,但下拉菜单总是有一点延迟。我希望有人能以某种方式帮助我:)
谢谢!
解决方案
问题是你没有看到你的子菜单?
我认为您没有指出悬停按钮时元素应具有的新位置:
.dropdown:hover .dropdown-content {left: 0;}
目前,您的元素保留在这里:
left:-999em;
祝你今天过得愉快,
推荐阅读
- oracle - 查询以计算 Oracle db CLOB 列中的不同值
- javascript - 使用多个键再次减少数据
- java - Gradle 下载并构建一个完整的项目
- php - 如何异步运行这个 PHP 进程
- java - 出现意外错误(类型=内部服务器错误,状态=500)。org/eclipse/jdt/internal/compiler/env/INameEnvironment
- java - 套接字编程,尝试连接到服务器会冻结应用程序和风车
- sql-server - 在 sqlserver 中比较 Varchar 时出现问题。使用 = 不起作用
- css - Css flexbox 条件包装
- visual-studio-code - 如何添加/编辑上下文菜单
- php - 从 html 中查找所有单词(或句子)