gpt4 book ai didi

jquery - 响应式下拉点击/悬停

转载 作者:行者123 更新时间:2023-11-28 09:52:13 31 4
gpt4 key购买 nike

我目前正在编写我的第一个响应式网站(总的来说我是一个初学者)并且我遇到了很多障碍。其中之一是我的菜单有问题。我会尽量具体。我有一个用于桌面的水平菜单和一个用于平板电脑/手机的垂直菜单。我不知道如何解决选项卡/mob 版本中的悬停问题。我有一个小的切换脚本来为下拉菜单设置动画,但每次我点击或悬停时它都会下拉。如何禁用悬停?我想从我的网站上完全删除悬停,但我不知道如何设置下拉菜单的样式。我想我已经尝试了一切。如果能帮助我完成脚本,我也将不胜感激。我将不胜感激任何帮助。

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$(".navbar li").click(function(){
$("li.nav_slide").slideToggle("fast");
});
});
</script>



<body>
<div class="container">
<nav>
<ul class="navbar">
<li><a href='#'><span aria-hidden="true" data-icon="&#xe600;" class="icon-home"></a></li>
<li><a href="sub/who_we_are.hmtl/">WHO WE ARE</a></li>
<li><a href="#">WHAT WE DO</a>
<ul>
<li class="nav_slide"><a href="sub/club_nights.html/">CLUB NIGHTS</a></li>
<li class="nav_slide"><a href="sub/festivals.html/">FESTIVALS</a></li>
</ul>
</li>
<li><a href="#">WHAT WE OFFER</a>
<ul>
<li class="nav_slide"><a href="sub/full_system.html/">FULL SYSTEM</a></li>
<li class="nav_slide"><a href="sub/individual_eq.html/">INDIVIDUAL EQ</a></li>
</ul>
</li>
</ul>
</nav>
</div>
</body>
<!--desktop-->
.container {
position: relative;
top: 0;
left: 0;
width: 800px;
height: 600px;
max-width: 1500px;
background-image: url('home.jpg');
background-repeat: no-repeat;
background-position: center;
margin: 0 auto 0 auto;
}

nav {
position: relative;
top: 430px;
left: 0;
margin: 0 auto 0 auto;
width: 600px;
height: 25px;
font-size: 15px;
}

nav ul {
position: relative;
top: 0;
left: 40px;
float: left;
height: 100%;
width: 100%;
list-style: none;
}

nav li {
position: relative;
display: inline;
padding: 0;
width: 135px;
float: left;
text-align: center;
}

nav li:first-child {
width: 30px;
}

li.menu_icons {
width: 80px;
text-align: right;
}

ul li a{
display: inline;
text-decoration: none;
}

ul li a:hover{
font-size: 16px;
text-align: center;
}

ul li ul{
display: none;
}

ul li:hover ul{
display: block; /* display the dropdown */
float: none;
background-color: #813C7D;
width: 135px;
position: relative;
top: 0;
left: 0;
}

ul li:hover li{
width: 100%;
background-color: #813C7D;
padding: 5px 5px 5px 5px;
}

li:hover li:last-child {
padding-bottom: 10px;
}

ul li:hover li a {
width: 100%;
text-align: center;
}

nav li a {
box-sizing:border-box;
-moz-box-sizing:border-box;
-webkit-box-sizing:border-box;
}

/* unvisited link */
a:link { color: white; }
/* visited link */
a:visited { color: white; }
/* selected link */
a:active { color: white; font-weight: bold; }

a:link { text-decoration: none; }
a:hover {text-decoration: none; }
a:visited { text-decoration: none; }
a:active{ text-decoration: none; }
}
}

<!--tab/mob-->


.container {
width: 100%;
max-width: 600px;
}

nav {
position: static;
width: 100%;
background: none;
font-size: 15px;
height: auto;
}

nav ul {
position: relative;
top: 0;
left: 0;
width: 100%;
margin: 0;
padding: 0;
background-color: #813C7D;
}

nav li {
padding: 0.25em 0;
text-align: center;
width: 100%;
}

nav li:first-child {
display: none;
}

nav li ul:first-child {
display: block;
}

ul li a{
text-decoration: none;
}

ul li ul li a{
text-align: center;
width: 100%;
}

.nav_slide {
width: 100%;
display: none;
}
}

最佳答案

尝试删除所有具有 :Hover

的 css

这会给出类似这样的结果:(它是否按预期工作?)

  .container {
position: relative;
top: 0;
left: 0;
width: 800px;
height: 600px;
max-width: 1500px;
background-image: url('home.jpg');
background-repeat: no-repeat;
background-position: center;
margin: 0 auto 0 auto;
}

nav {
position: relative;
top: 430px;
left: 0;
margin: 0 auto 0 auto;
width: 600px;
height: 25px;
font-size: 15px;
}

nav ul {
position: relative;
top: 0;
left: 40px;
float: left;
height: 100%;
width: 100%;
list-style: none;
}

nav li {
position: relative;
display: inline;
padding: 0;
width: 135px;
float: left;
text-align: center;
}

nav li:first-child {
width: 30px;
}

li.menu_icons {
width: 80px;
text-align: right;
}

ul li a{
display: inline;
text-decoration: none;
}

ul li ul{
display: none;
}

nav li a {
box-sizing:border-box;
-moz-box-sizing:border-box;
-webkit-box-sizing:border-box;
}

/* unvisited link */
a:link { color: white; }
/* visited link */
a:visited { color: white; }
/* selected link */
a:active { color: white; font-weight: bold; }

a:link { text-decoration: none; }
a:hover {text-decoration: none; }
a:visited { text-decoration: none; }
a:active{ text-decoration: none; }


<!--tab/mob-->


.container {
width: 100%;
max-width: 600px;
}

nav {
position: static;
width: 100%;
background: none;
font-size: 15px;
height: auto;
}

nav ul {
position: relative;
top: 0;
left: 0;
width: 100%;
margin: 0;
padding: 0;
background-color: #813C7D;
}

nav li {
padding: 0.25em 0;
text-align: center;
width: 100%;
}

nav li:first-child {
display: none;
}

nav li ul:first-child {
display: block;
}

ul li a{
text-decoration: none;
}

ul li ul li a{
text-align: center;
width: 100%;
}

.nav_slide {
width: 100%;
display: none;
}

关于jquery - 响应式下拉点击/悬停,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25037046/

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