gpt4 book ai didi

html - 每当我从导航菜单移动到下拉菜单时,悬停后​​下拉菜单就会消失

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

*,
*::before,
*::after {
margin: 0px;
padding: 0px;
box-sizing: inherit;
}

body {
font-size: 62.5%;
box-sizing: border-box;
}

.navigation {
text-transform: uppercase;
font-family: Cambria, Cochin, Georgia, Times, 'Times New Roman', serif;
font-size: 1.2rem;
background-color: #390238;
}

.navigation::after {
content: "";
display: table;
clear: both;
}

.navigation-primary {
float: right;
list-style: none;
}

.navigation-primary--item {
display: inline-block;
width: 12rem;
position: relative;
}

.navigation-primary--item a {
text-align: center;
padding: 1rem;
color: #eee;
text-decoration: none;
display: block;
}

.navigation-primary--item a:hover {
background-color: #520350;
}

.navigation-primary--item a:hover+ul {
opacity: 1;
margin: 0;
}

.navigation-primary--item-main {
opacity: 0;
position: absolute;
width: 100%;
top: 100%;
z-index: -1;
background-color: #390238;
box-shadow: 0px 5px 10px rgba(0, 0, 0, 0.8);
}

.navigation-primary--item-main-sub {
list-style: none;
widows: 100%;
position: relative;
}

.navigation-primary--item-main-sub a {
text-decoration: none;
color: #eee;
text-align: center;
display: block;
}

.navigation-primary--item-main-sub a:hover {
background-color: #520350;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="style.css">

<title>Navigation Dropdown Using Float</title>
</head>
<body>
<nav class="navigation">
<ul class="navigation-primary">
<li class="navigation-primary--item"><a href="#">Home</a>
<ul class="navigation-primary--item-main">
<li class="navigation-primary--item-main-sub"><a href="#">Home Subitem</a></li>
<li class="navigation-primary--item-main-sub"><a href="#">Home Subitem</a></li>
<li class="navigation-primary--item-main-sub"><a href="#">Home Subitem</a></li>
<li class="navigation-primary--item-main-sub"><a href="#">Home Subitem</a></li>
</ul>
</li>
<li class="navigation-primary--item"><a href="#">About Us</a>
<ul class="navigation-primary--item-main">
<li class="navigation-primary--item-main-sub"><a href="#">About Us Subitem</a></li>
<li class="navigation-primary--item-main-sub"><a href="#">About Us Subitem</a></li>
<li class="navigation-primary--item-main-sub"><a href="#">About Us Subitem</a></li>
<li class="navigation-primary--item-main-sub"><a href="#">About Us Subitem</a></li>
</ul>
</li>
<li class="navigation-primary--item"><a href="#">Contact Us</a>
<ul class="navigation-primary--item-main">
<li class="navigation-primary--item-main-sub"><a href="#">Contact Us Subitem</a></li>
<li class="navigation-primary--item-main-sub"><a href="#">Contact Us Subitem</a></li>
<li class="navigation-primary--item-main-sub"><a href="#">Contact Us Subitem</a></li>
<li class="navigation-primary--item-main-sub"><a href="#">Contact Us Subitem</a></li>
</ul>
</li>
<li class="navigation-primary--item"><a href="#">LogOut</a></li>
</ul>
</nav>
</body>
</html>

创建了一个下拉菜单,当我将鼠标悬停时,下拉菜单会出现,当我将光标移动到下拉菜单时,悬停后​​它会消失。注意:下拉菜单和导航栏之间没有间隙

创建了一个下拉菜单,当我将鼠标悬停时,下拉菜单会出现,当我将光标移动到下拉菜单时,悬停后​​它会消失。注意:下拉菜单和导航栏之间没有间隙

创建了一个下拉菜单,当我将鼠标悬停时,下拉菜单会出现,当我将光标移动到下拉菜单时,悬停后​​它会消失。注意:下拉菜单和导航栏之间没有间隙

最佳答案

我以前遇到过这个问题,但不记得我是如何解决它的,但可能只是将子菜单 block 提高一两个像素,并带有负边距顶部。

关于html - 每当我从导航菜单移动到下拉菜单时,悬停后​​下拉菜单就会消失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57129036/

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