Space between menu and drop down menu(菜单和下拉菜单之间的空间)
问题描述
我希望下拉菜单显示在主菜单区域的边框线下方,而不是显示在菜单"标题/按钮的正下方.我可以更改定位,使其更低,但中间有死区,无法将鼠标悬停在下拉菜单上.
I'd like for the drop down menu to show below the border line in the main menu area instead of showing up right underneath the 'menu' title/button. I can change the positioning so that it is lower but then there is dead space in between that makes it impossible to mouse over the drop down menu.
我不想在下拉列表上方添加填充,因为这只会创建更多紫色空间,我希望该空间为空.
I don't want to add padding above the drop down because that just created more purple space, where I want that space to be empty.
以下是代码,您可以在这里查看:链接
Below is the code but feel free to view here: link
html:
<div class="menu-box fl">
<ul class="menu">
<!-- Begin Item With Drop -->
<li class="drop">
<a href="#"><span class="big-text">menu</span></a>
<!-- Begin Toggle Icon -->
<span class="toggle"> </span>
<!-- End Toggle Icon -->
<ul>
<li><a href="#">CSS & XHTML</a></li>
<li><a href="#">Javascript</a></li>
<li><a href="#">Photoshop</a></li>
<li><a href="#">Illustrator</a></li>
<li><a href="#">Dreamweaver</a></li>
</ul>
</li>
<!-- End Item With Drop -->
</ul>
</div><!--end menu-->
<div class="social fl">
</div><!-- end social-->
<div class="email fr">
</div><!--end email-->
<div class="clear"></div>
</div><!--end nav-inner-->
</div><!--end nav-->
CSS:
.nav {
height: 65px;
width: 100%;
border-bottom-width: 1px;
border-bottom-style: solid;
border-bottom-color: #999;
font-family: 'Raleway', sans-serif;
}
.nav-inner {
width:1000px;
margin-left:auto;
margin-right:auto;
height:65px;
}
.menu-box {
width: 200px;
height: 100%;
border-right-width: 1px;
border-right-style: solid;
border-right-color: #999;
}
ul.menu {
list-style-type:none;
margin:0;
padding:20px 0 0 6px;
position:relative;
float: right;
}
ul.menu li {
display:block;
height: 30px;
float:left;
position:relative;
margin:0 9px 0 0;
padding:0;
width:140px;
filter: alpha(opacity=75); /* internet explorer */
-khtml-opacity: 0.75; /* khtml, old safari */
-moz-opacity: 0.75; /* mozilla, netscape */
opacity: 0.75; /* fx, safari, opera */
}
li.drop a {
color:#333;
line-height:30px;
}
ul.menu li ul li a {
color:#ffffff;
}
ul.menu li:hover {
width:140px;
color:#fffff;
}
.big-text {
font-size:1.5em;
}
ul.menu li.drop span.toggle {
display:block;
float:left;
width:31px;
height:30px;
background:transparent url("images/toggle1.png") no-repeat 0 -30px;
padding:0;
margin:0 7px 0 0;
color:#ffffff;
cursor:pointer;
}
ul.menu li.drop:hover span.toggle, ul.menu li.drop.current span.toggle {
background-position:0px 0px;
}
ul.menu li.drop:hover ul {-webkit-border-radius: 5px;
border-radius: 5px;
display:block;
z-index:1;
position: absolute;
z-index:100;
}
ul.menu li ul {
display:none;
position:absolute;
width: 100%;
top:30px;
left:0;
list-style-type:none;
padding-top:10px;
background:#461b47;
filter: alpha(opacity=75); /* internet explorer */
}
ul.menu li ul li {
float: none;
height: auto;
margin: 0;
filter: alpha(opacity=100); /* internet explorer */
color: #ffffff;
border-bottom-width: thin;
border-top-style: none;
border-right-style: none;
border-bottom-style: solid;
border-left-style: none;
border-bottom-color: #FFF;
padding-top: 10px;
padding-right: 0px;
padding-bottom: 0px;
padding-left: 0px;
}
ul.menu li ul li a {
padding-left:5px;
padding-right:5px;
}
.social {
width:300px;
height:100%;
}
.email {
width:500px;
height:100%;
}
推荐答案
尝试在你的 css 中改变这两件事:
Try changing these two things in your css:
ul.menu li {
display:block;
height: 50px; /* CHANGED THIS FROM 30px TO 50px */
float:left;
position:relative;
margin:0 9px 0 0;
padding:0;
width:140px;
filter: alpha(opacity=75); /* internet explorer */
-khtml-opacity: 0.75; /* khtml, old safari */
-moz-opacity: 0.75; /* mozilla, netscape */
opacity: 0.75; /* fx, safari, opera */
}
ul.menu li ul {
display:none;
position:absolute;
width: 100%;
top:30px;
margin-top: 18px; /* ADDED THIS VALUE */
left:0;
list-style-type:none;
padding-top:10px;
background:#461b47;
filter: alpha(opacity=75); /* internet explorer */
}
看到这个JSFiddle
我认为应该在不干扰页面布局的情况下实现您的需求.
I think that should achieve what you need without interfering with the layout of the page.
这篇关于菜单和下拉菜单之间的空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:菜单和下拉菜单之间的空间
基础教程推荐
- 我什么时候应该在导入时使用方括号 2022-01-01
- 在 JS 中获取客户端时区(不是 GMT 偏移量) 2022-01-01
- Karma-Jasmine:如何正确监视 Modal? 2022-01-01
- 角度Apollo设置WatchQuery结果为可用变量 2022-01-01
- 当用户滚动离开时如何暂停 youtube 嵌入 2022-01-01
- 动态更新多个选择框 2022-01-01
- 响应更改 div 大小保持纵横比 2022-01-01
- 在for循环中使用setTimeout 2022-01-01
- 有没有办法使用OpenLayers更改OpenStreetMap中某些要素 2022-09-06
- 悬停时滑动输入并停留几秒钟 2022-01-01