javascript - 鼠标悬停在Angular 6中打开menga菜单
问题描述
我是 Angular 6 和 Bootstrap 的新手,这里有一个带有 3 个导航项的导航栏。
在这个我有一个名为 Store 的导航项,当用户鼠标悬停在 Store 上时,我需要显示一个超级菜单。超级菜单应该有导航栏的 with。
我已经尝试了一些东西,但我无法得到我所期望的。
Stackblitz:https ://stackblitz.com/edit/angular-q4p7cc?file=src%2Fstyles.css
谁能帮我解决这个问题。
解决方案
HTML:
<div class="navbar">
<div *ngFor="let cat of category" class="dropdown">
<button class="dropbtn">Link {{cat.catnumber}}
<i class="fa fa-caret-down"></i>
</button>
<div class="dropdown-content">
<div class="row">
<div *ngFor="let catg of cat.nest" class="column">
<h3>Category {{cat.catnumber}} {{catg.link}} </h3>
<a href="#">Link 1</a>
<a href="#">Link 2</a>
<a href="#">Link 3</a>
</div>
</div>
</div>
</div>
</div>
样式.css:
.navbar {
overflow: hidden;
background-color: #333;
font-family: Arial, Helvetica, sans-serif;
}
.navbar a {
float: left;
font-size: 16px;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
.dropdown {
float: left;
overflow: hidden;
}
.dropdown .dropbtn {
font-size: 16px;
border: none;
outline: none;
color: white;
padding: 14px 16px;
background-color: inherit;
font: inherit;
margin: 0;
}
.navbar a:hover, .dropdown:hover .dropbtn {
background-color: red;
}
.dropdown-content {
display: none;
position: fixed;
background-color: #f9f9f9;
width: 100%;
left: 0;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
}
.dropdown-content .header {
background: red;
padding: 16px;
color: white;
}
.dropdown:hover .dropdown-content {
background: yello;
display: block;
}
/* Create three equal columns that floats next to each other */
.column {
float: left;
width: 50%;
padding: 10px;
background-color: #ccc;
height: 250px;
}
.column a {
float: none;
color: black;
padding: 16px;
text-decoration: none;
display: block;
text-align: left;
}
.column a:hover {
background-color: #ddd;
}
/* Clear floats after the columns */
.row:after {
content: "";
display: table;
clear: both;
}
推荐阅读
- sql-server - SQL Select * Into From 语句中的逻辑
- python - Python并行保存数据
- arrays - 我需要一个函数来显示堆叠的矩阵
- python-3.x - python中数据透视表上的条件格式(突出显示)
- c# - 事件触发后 Blazor 组件不刷新
- java - 为什么在 SortedSet 接口中指定了 subSet 方法而不是 Set?
- android - Visual Studio 2019 社区版是否支持安卓模拟器?
- python - 调试 Python 导入失败 (ModuleNotFoundError)
- typescript - TypeScript:在使用接口的对象中传递嵌套函数的 ReturnType
- c++ - pthread_spinlock 是否会导致从用户空间切换到内核空间