gpt4 book ai didi

html - 我的下拉菜单的内容关闭得太快

转载 作者:行者123 更新时间:2023-11-27 22:26:39 30 4
gpt4 key购买 nike

我正在构建一个站点,但我遇到了这个问题......当我将鼠标悬停在 li 元素上并显示子菜单时,我无法点击其中的任何内容,因为它关闭得非常快:/我发现类似的这里已经有问题和解决方案,尝试实现它们但没有成功:/(JSFiddle Link; http://jsfiddle.net/qbNLN/1 )

HTML代码:

<ul class="main_navigation" role="menubar">
<li role="menuitem">
<a href="#" class="link">Compre por Marcas</a>
<div class="balloon balloon_big">
<span class="balloon_top" style="left: 38px;"></span>
<p class="base-title"><strong>Compre por Marcas</strong></p>
<div class="menucolumns">
<div class="column1">
<ul class="submenuitems column1">
<li><a href="#" title="4 Plus Nutrition">4 Plus Nutrition</a></li>
</ul>
</div>
<div class="column1">
<ul class="submenuitems column1">
<li><a href="#" title="Hayabusa">Hayabusa</a></li>
</ul>
</div>
<div class="column1">
<ul class="submenuitems column1">
<li><a href="#" title="Pacific Health">Pacific Health</a></li>
</ul>
</div>
</div>
</div>
</li>
<li role="menuitem">
<a href="#" class="link">Compre por Objetivo</a>
<div class="balloon">
<span class="balloon_top" style="left: 38px;"></span>
<p class="base-title"><strong>Compre por Objetivo</strong></p>
<ul class="submenuitems">
<li><a href="/" class="main-submenu-lnk">Camisas</a></li>
</ul>
</div>
</li>
<li role="menuitem">
<a href="#" class="link">Compre por Categoria</a>
<div class="balloon">
<span class="balloon_top" style="left: 38px;"></span>
<p class="base-title"><strong>Compre por Categoria</strong></p>
<ul class="submenuitems">
<li><a href="/" class="main-submenu-lnk">Camisas</a></li>
</ul>
</div>
</li>

CSS 代码:

            .main_navigation {
margin: 0 auto;
padding: 0;
vertical-align: top;
background: #304e89;
border-left: rgba(0,0,0,0.4) 1px solid;
border-right: rgba(255,255,255,0.1) 1px solid;
font-size: 0;
min-width:960px;
width:1170px;
}
.main_navigation>li, .main_navigation .main_navigation-item {
font-size: 12px;
position: relative;
vertical-align: top;
float:left;
list-style:none;
list-style-type:none;
font-weight:bold;
}
.main_navigation>li>a {
color: #fff;
padding: 11px 10px 9px;
display: block;
font-size: 13px;
line-height: 20px;
min-height: 20px;
text-decoration: none;
font-family: "DIN", sans-serif;
background-color: #304e89;
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #304e89), color-stop(100%, #253e6f));
background-image: -webkit-linear-gradient(top, #304e89, #253e6f);
background-image: -moz-linear-gradient(top, #304e89, #253e6f);
background-image: -ms-linear-gradient(top, #304e89, #253e6f);
background-image: -o-linear-gradient(top, #304e89, #253e6f);
background-image: linear-gradient(top, #304e89, #253e6f);
border-left: rgba(255,255,255,0.1) 1px solid;
border-right: rgba(0,0,0,0.4) 1px solid
}
.main_navigation>li> .link {
text-transform:uppercase;
}
.main_navigation .balloon {
display:none;
position:absolute;
top: 45px;
left:0;
z-index: 100;
}
.main_navigation li:hover .balloon_top {
width: 0px;
height: 0px;
border: 0;
padding: 0;
display: block;
position: absolute;
top: 0
}
.main_navigation .balloon_top:after {
border-bottom-color: #ececec
}
.balloon .base-title {
margin: -15px -15px 0 -15px;
padding: 10px 15px;
background: #ececec;
border-bottom: #ddd 1px solid
}
.main_navigation .balloon {
top:50px;
border: 1px solid #ccc;
-webkit-border-radius:3px;
-moz-border-radius:3px;
border-radius:3px;
}
.balloon, .balloon_top, .balloon-right, .balloon-left, .balloon-bottom, .mini-modal {
padding: 15px;
position: relative;
background: #fff;
text-align: left;
border: #ddd 1px solid;
color: #333;
font-size: 12px;
font-family: Arial, sans-serif;
text-transform: none;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
border-radius: 3px
}
.balloon_top:after {
width: 0;
height: 0;
content: " ";
border: 7px solid rgba(255,255,255,0);
border/*\**/: 7px solid transparent\9;
border-bottom-color: #fff;
border-top-width: 0;
position: absolute;
pointer-events: none;
bottom: 100%;
left: 50%;
margin-left: -7px
}
.balloon_top:before {
width: 0;
height: 0;
content: " ";
border: 9px solid rgba(221,221,221,0);
border/*\**/: 9px solid transparent\9;
border-bottom-color: #ddd;
border-top-width: 0;
position: absolute;
pointer-events: none;
bottom: 100%;
left: 50%;
margin-left: -9px
}
.balloon-right:after {
width: 0;
height: 0;
content: " ";
border: 7px solid rgba(255,255,255,0);
border/*\**/: 7px solid transparent\9;
border-left-color: #fff;
border-right-width: 0;
position: absolute;
pointer-events: none;
left: 100%;
top: 50%;
margin-top: -7px
}
.balloon-right:before {
width: 0;
height: 0;
content: " ";
border: 9px solid rgba(221,221,221,0);
border/*\**/: 9px solid transparent\9;
border-left-color: #ddd;
border-right-width: 0;
position: absolute;
pointer-events: none;
left: 100%;
top: 50%;
margin-top: -9px
}
.balloon-left:after {
width: 0;
height: 0;
content: " ";
border: 7px solid rgba(255,255,255,0);
border/*\**/: 7px solid transparent\9;
border-right-color: #fff;
border-left-width: 0;
position: absolute;
pointer-events: none;
top: 50%;
right: 100%;
margin-top: -7px
}
.balloon-left:before {
width: 0;
height: 0;
content: " ";
border: 9px solid rgba(221,221,221,0);
border/*\**/: 9px solid transparent\9;
border-right-color: #ddd;
border-left-width: 0;
position: absolute;
pointer-events: none;
top: 50%;
right: 100%;
margin-top: -9px
}
.balloon-bottom:after {
width: 0;
height: 0;
content: " ";
border: 7px solid rgba(255,255,255,0);
border/*\**/: 7px solid transparent\9;
border-top-color: #fff;
border-bottom-width: 0;
position: absolute;
pointer-events: none;
top: 100%;
left: 50%;
margin-left: -7px
}
.balloon-bottom:before {
width: 0;
height: 0;
content: " ";
border: 9px solid rgba(221,221,221,0);
border/*\**/: 9px solid transparent\9;
border-top-color: #ddd;
border-bottom-width: 0;
position: absolute;
pointer-events: none;
top: 100%;
left: 50%;
margin-left: -9px
}
.main_navigation .balloon_big {
width:1000px;
}
.main_navigation .balloon .submenuitems {
list-style:none;
list-style-type:none;
padding:10px 0 0 0;
margin:0;
}
.main_navigation .balloon .menucolumns {
border:1px dashed #000;
clear:both;
overflow:hidden;
}
.main_navigation .balloon .menucolumns .column1 {
float:left;
min-width:150px;
max-width:200px;
}

谢谢你们,我们将不胜感激!

最佳答案

纯 CSS 解决方案: Fiddle

使用 .main_navigation>li:hover .balloon 而不是 .main_navigation>li a:hover + .balloon,即使鼠标悬停在气球上也能确保气球保持打开状态。

然后添加,

.balloon:before {
display: block;
content: "";
width: 100%;
height: 10px;
position: absolute;
top: -10px;
left: 0;
}

在菜单和气球之间添加一个不可见的 block 。

关于html - 我的下拉菜单的内容关闭得太快,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20910239/

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