简体   繁体   English

将鼠标悬停以在Angular 6中打开菜单

[英]Mouse hover to open menga menu in Angular 6

I am new to Angular 6 and Bootstrap ,Here I have a Navigation bar with 3 nav items . 我是Angular 6和Bootstrap的新手,这里有一个包含3个导航项的导航栏。

In this I have a nav item named as Store ,When User mouse hover on the Store I need to show a mega menu .mega menu should have the with of the nav bar . 在这里,我有一个名为Store的导航项,当用户将鼠标悬停在Store上时,我需要显示一个超级菜单。mega菜单应具有导航栏的with。

I have tried something but I could not get what I expected . 我已经尝试了一些东西,但是无法达到预期的效果。

Stackblitz : https://stackblitz.com/edit/angular-q4p7cc?file=src%2Fstyles.css Stackblitz: https ://stackblitz.com/edit/angular-q4p7cc ? file = src%2Fstyles.css

can anyone help me to solve this . 谁能帮我解决这个问题。

try solution 尝试解决方案

HTML: 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>

style.css: style.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;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM