gpt4 book ai didi

javascript - 下拉菜单的问题

转载 作者:行者123 更新时间:2023-11-29 18:04:17 25 4
gpt4 key购买 nike

我不知道下拉菜单会发生什么,当我移动鼠标时我无法触摸下拉菜单:(我尝试用一​​条线,修改填充,它让我移动所有的线..就是全部关于下面的代码..只是你能为我做什么,非常感谢

(function ($) {
$(document).ready(function () {
$('#cssmenu').prepend('<div id="indicatorContainer"><div id="pIndicator"><div id="cIndicator"></div></div></div>');
var activeElement = $('#cssmenu>ul>li:first');

$('#cssmenu>ul>li').each(function () {
if ($(this).hasClass('active')) {
activeElement = $(this);
}
});


var posLeft = activeElement.position().left;
var elementWidth = activeElement.width();
posLeft = posLeft + elementWidth / 2 - 6;
if (activeElement.hasClass('has-sub')) {
posLeft -= 6;
}

$('#cssmenu #pIndicator').css('left', posLeft);
var element, leftPos, indicator = $('#cssmenu pIndicator');

$("#cssmenu>ul>li").hover(function () {
element = $(this);
var w = element.width();
if ($(this).hasClass('has-sub')) {
leftPos = element.position().left + w / 2 - 12;
}
else {
leftPos = element.position().left + w / 2 - 6;
}

$('#cssmenu #pIndicator').css('left', leftPos);
}
, function () {
$('#cssmenu #pIndicator').css('left', posLeft);
});

$('#cssmenu>ul').prepend('<li id="menu-button"><a>Menu</a></li>');
$("#menu-button").click(function () {
if ($(this).parent().hasClass('open')) {
$(this).parent().removeClass('open');
}
else {
$(this).parent().addClass('open');
}
});
});
})(jQuery);
#cssmenu {
position: relative;
height: 30px;
width: auto;
display: inline-block;
margin-top: 3px;
box-sizing: border-box;
}

#cssmenu ul {
list-style: none;
padding: 0;
margin: 0;
line-height: 1;
}

#cssmenu > ul {
position: relative;
display: block;
width: 100%;
z-index: 500;
}

#cssmenu:after,
#cssmenu > ul:after {
content: ".";
display: block;
clear: both;
visibility: hidden;
line-height: 0;
height: 0;
}

#cssmenu.align-right > ul > li {
float: right;
}

#cssmenu.align-center ul {
text-align: center;
}

#cssmenu.align-center ul ul {
text-align: left;
}

#cssmenu > ul > li {
display: inline-block;
position: relative;
margin: 0;
padding: 0;
}

#cssmenu > ul > #menu-button {
display: none;
}

#cssmenu ul li a {
display: block;
font-family: Helvetica, sans-serif;
text-decoration: none;
}

#cssmenu > ul > li > a {
font-size: 14px;
font-weight: bold;
padding: 0px 20px;
color: #7a8189;
text-transform: uppercase;
-webkit-transition: color 0.25s ease-out;
-moz-transition: color 0.25s ease-out;
-ms-transition: color 0.25s ease-out;
-o-transition: color 0.25s ease-out;
transition: color 0.25s ease-out;
}

#cssmenu > ul > li.has-sub > a {
padding-right: 32px;
}

#cssmenu > ul > li:hover > a {
color: #ffffff;
}

#cssmenu li.has-sub::after {
display: block;
content: "";
position: absolute;
width: 0;
height: 0;
}

#cssmenu > ul > li.has-sub::after {
right: 18px;
top: 6px;
border: 5px solid transparent;
border-top-color: #7a8189;
}

#cssmenu > ul > li:hover::after {
border-top-color: #ffffff;
}

#indicatorContainer {
position: absolute;
height: 12px;
width: 100%;
bottom: 0px;
overflow: hidden;
z-index: -1;
}

#pIndicator {
position: absolute;
height: 0;
width: 100%;
border: 12px solid transparent;
border-top-color: #2b2f3a;
z-index: -2;
-webkit-transition: left .25s ease;
-moz-transition: left .25s ease;
-ms-transition: left .25s ease;
-o-transition: left .25s ease;
transition: left .25s ease;
}

#cIndicator {
position: absolute;
height: 0;
width: 100%;
border: 12px solid transparent;
border-top-color: #2b2f3a;
top: -12px;
right: 100%;
z-index: -2;
}

#cssmenu ul ul {
position: absolute;
left: -9999px;
top: 70px;
opacity: 0;
-webkit-transition: opacity .3s ease, top .25s ease;
-moz-transition: opacity .3s ease, top .25s ease;
-ms-transition: opacity .3s ease, top .25s ease;
-o-transition: opacity .3s ease, top .25s ease;
transition: opacity .3s ease, top .25s ease;
z-index: 1000;
}

#cssmenu ul ul ul {
top: 37px;
padding-left: 5px;
}

#cssmenu ul ul li {
position: relative;
}

#cssmenu > ul > li:hover > ul {
left: auto;
top: 44px;
opacity: 1;
}

#cssmenu.align-right > ul > li:hover > ul {
left: auto;
right: 0;
opacity: 1;
}

#cssmenu ul ul li:hover > ul {
left: 170px;
top: 0;
opacity: 1;
}

#cssmenu.align-right ul ul li:hover > ul {
left: auto;
right: 170px;
top: 0;
opacity: 1;
padding-right: 5px;
}

#cssmenu ul ul li a {
width: 130px;
border-bottom: 1px solid #eeeeee;
padding: 10px 20px;
font-size: 12px;
color: #9ea2a5;
background: #ffffff;
-webkit-transition: all .35s ease;
-moz-transition: all .35s ease;
-ms-transition: all .35s ease;
-o-transition: all .35s ease;
transition: all .35s ease;
}

#cssmenu.align-right ul ul li a {
text-align: right;
}

#cssmenu ul ul li:hover > a {
background: #f2f2f2;
color: #8c9195;
}

#cssmenu ul ul li:last-child > a,
#cssmenu ul ul li.last > a {
border-bottom: 0;
}

#cssmenu > ul > li > ul::after {
content: '';
border: 6px solid transparent;
width: 0;
height: 0;
border-bottom-color: #ffffff;
position: absolute;
top: -12px;
left: 30px;
}

#cssmenu.align-right > ul > li > ul::after {
left: auto;
right: 30px;
}

#cssmenu ul ul li.has-sub::after {
border: 4px solid transparent;
border-left-color: #9ea2a5;
right: 10px;
top: 12px;
-moz-transition: all .2s ease;
-ms-transition: all .2s ease;
-o-transition: all .2s ease;
transition: all .2s ease;
-webkit-transition: -webkit-transform 0.2s ease, right 0.2s ease;
}

#cssmenu.align-right ul ul li.has-sub::after {
border-left-color: transparent;
border-right-color: #9ea2a5;
right: auto;
left: 10px;
}

#cssmenu ul ul li.has-sub:hover::after {
border-left-color: #ffffff;
right: -5px;
-webkit-transform: rotateY(180deg);
-ms-transform: rotateY(180deg);
-moz-transform: rotateY(180deg);
-o-transform: rotateY(180deg);
transform: rotateY(180deg);
}

#cssmenu.align-right ul ul li.has-sub:hover::after {
border-right-color: #ffffff;
border-left-color: transparent;
left: -5px;
-webkit-transform: rotateY(180deg);
-ms-transform: rotateY(180deg);
-moz-transform: rotateY(180deg);
-o-transform: rotateY(180deg);
transform: rotateY(180deg);
}
<!DOCTYPE html>
<html>
<header></header>
<body>
<div class="subheader">
<div class="user_inside">
<p>Welcome Giocconda</p>
<div id="cssmenu">
<ul>
<li class='active has-sub'><a href='#'><img src="images/profile_icn.png"></a>
<ul>
<li class='has-sub'><a href='#'><span>Product 1</span></a></li>
<li class='has-sub'><a href='#'><span>Product 2</span></a></li>
</ul>
</li>
</ul>
</div>
</div>
</div>
</body>
</html>

最佳答案

#cssmenu ul ul{
position: absolute;
left: 0px;
top: 50px;
opacity: 0;
-webkit-transition: opacity .3s ease, top .25s ease;
-moz-transition: opacity .3s ease, top .25s ease;
-ms-transition: opacity .3s ease, top .25s ease;
-o-transition: opacity .3s ease, top .25s ease;
transition: opacity .3s ease, top .25s ease;
z-index: 1000;
}

在 css 中更改左侧位置

关于javascript - 下拉菜单的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32496754/

25 4 0