子菜单的悬停状态比右侧宽30px。如果我更改填充它会影响所有内容,而不仅仅是悬停状态。我已经绞尽脑汁待了几个小时,所以我希望有一双眼睛能够找出我所缺少的东西。
这是HTML:
<DOCTYPE html>
<html>
<head>
<meta harset="utf-8">
<link rel="stylesheet" type="text/css" href="css/drop.css">
<title>CSS3 Pricing Tables</title>
</head>
<body>
<nav id="nav" role="navigation">
<a href="#nav" title="Show navigation">Show navigation</a>
<a href="#" title="Hide navigation">Hide navigation</a>
<ul class="menu" id="clearfix">
<li id="active"><a href="#">Home</a></li>
<li><a href="#">Products</a>
<ul>
<li><a href="#" class="infinity">NeuroSolutions Infinity</a>
<li><a href="#" class="ns">NeuroSolutions</a>
<li><a href="#" class="ns4ml">NeuroSolutions for MATLAB</a>
<li><a href="#" class="csw">Custom Solution Wizard</a>
</ul>
</li>
<li><a href="#">Custom Services</a> </li>
<li><a href="#">Customers</a>
<ul>
<li><a href="#" class="case-studies">Case Studies</a>
<li><a href="#" class="testimonials">Testimonials</a>
</ul>
</li>
<li><a href="#">Support</a>
<ul>
<li><a href="#" class="app">Documentation</a>
<li><a href="#" class="website">Intro to Neural Networks</a>
<li><a href="#" class="website">Maintenance</a>
<li><a href="#" class="website">Newsletter Archive</a>
<li><a href="#" class="website">Video Library</a>
</ul>
</li>
<li><a href="#">Order</a></li>
</ul>
</nav>
</body>
</html>
这是CSS:
#clearfix:after {
visibility: hidden;
display: block;
font-size: 0;
content: " ";
clear: both;
eight: 0;
}
* html #clearfix {
zoom: 1;
}
*:first-child+html .clearfix {
zoom: 1;
}
/* Reset */
.menu, .menu ul, .menu li, .menu a {
margin: 0;
padding: 0;
border: none;
outline: none;
}
#nav {
width: 100%;
height: 40px;
margin: 0;
padding: 0;
background-color: #4f4f4f;
background: linear-gradient(top, #4f4f4f 0%, #343434 100%);
background: -moz-linear-gradient(top, #4f4f4f 0%, #343434 100%);
background: -webkit-linear-gradient(top, #4f4f4f 0%, #343434 100%);
background: -ms-linear-gradient(top, #4f4f4f 0%, #343434 100%);
}
.menu {
height: 40px;
padding-left: 3%;
width: auto;
background-color: #4C4E5A;
margin: 0;
border-radius: 5px;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
background: linear-gradient(top, #4f4f4f 0%, #343434 100%);
background: -moz-linear-gradient(top, #4f4f4f 0%, #343434 100%);
background: -webkit-linear-gradient(top, #4f4f4f 0%, #343434 100%);
background: -ms-linear-gradient(top, #4f4f4f 0%, #343434 100%);
}
#nav > a {
display: none;
}
#nav li {
list-style: none;
float: left;
display: block;
height: 40px;
margin: 0;
position: relative;
z-index: 1;
}
#nav li a {
display: block;
text-decoration: none;
font-weight: bold;
color: #FFF;
font-size: 85%;
padding: 0 15px;
margin: 0;
line-height: 40px;
}
#nav li:first-child a { border-left: none; }
#nav li:last-child a { border-left: none; }
#nav li:hover > a { background-color: #4685d2; color: #FFF; }
#nav li a:active {
background-color: #4685d2 !important;
}
/* first level */
#nav > ul {
height: 100%;
}
#nav > ul > li {
height:100%;
float: left;
}
#nav > ul > li > a {
height:100%;
text-align: center;
}
/* second level */
.menu ul {
position: absolute;
width: 250px;
padding: 0;
margin: 0;
opacity: 0;
background: #343434;
transition: opacity .25s ease .1s;
-moz-transition: opacity .25s ease .1s;
-webkit-transition: opacity .25s ease .1s;
-ms-transition: opacity .25s ease .1s;
}
.menu li:hover > ul {
opacity: 1;
}
.menu ul li {
height: 0;
overflow: hidden;
padding: 0;
}
.menu li:hover > ul li {
height: auto;
overflow: visible;
}
.menu ul li a {
width: 250px;
margin: 0;
padding: 5px 15px;
border: none;
}
.menu ul li:first-child a { border: none; }
#nav li:hover ul {
display:block;
width: 250px;
padding: 0;
margin: 0;
}
@media only screen and ( max-width:62.5em ) /* 1000 */ {
#nav {
width:100%;
position:static;
margin:0;
}
}
@media only screen and ( max-width:40em ) /* 640 */ {
html {
font-size:75%;
/* 12 */
}
#nav {
position:relative;
top:auto;
left: auto;
}
#nav>a {
width:3.125em;/* 50 */
height:3.125em;/* 50 */
text-align:left;
text-indent:-9999px;
background-color:#e15a1f;
position:relative;
}
#nav>a:before, #nav>a:after {
position:absolute;
border:2px solid #fff;
top:35%;
left:25%;
right:25%;
content:'';
}
#nav>a:after {
top:60%;
}
#nav:not(:target )>a:first-of-type, #nav:target>a:last-of-type {
display: block;
}
/* first level */
#nav>ul {
height:auto;
display:none;
position:absolute;
left:0;
right:0;
}
#nav:target>ul {
display:block;
}
#nav>ul>li {
width:100%;
float:none;
}
#nav>ul>li>a {
height:auto;
text-align:left;
padding:0 0.833em;
/* 20 (24) */
}
#nav>ul>li:not(:last-child )>a {
border-right:none;
border-bottom: 1px solid #cc470d;
}
/* second level */
#nav li ul {
position:static;
padding:1.25em;/* 20 */
padding-top:0;
}
}
答案 0 :(得分:0)
menu li ul li a:hover {
width: 220px;
}
将上面的类添加到CSS.Hope上面的代码工作
答案 1 :(得分:0)
你的意图是什么:
#nav li ul {
position:static;
padding:1.25em;/* 20 */
padding-top:0;
}
我删除了'padding:1.25em',看起来不错:http://jsfiddle.net/b3fhv/1/