这就是我想要做的:
示例代码:
#mainnav-menu {
float: left;
width: 101%;
list-style-type: none;
list-style-position: outside;
position: relative;
background-color: #389c0c;
-webkit-box-shadow: 0 10px 8px -6px black;
-moz-box-shadow: 0 10px 8px -6px black;
box-shadow: 0 10px 8px -6px black;
}
#mainnav-menu li {
float:left;
position:relative;
margin-right: 1px;
}
#mainnav-menu a {
display: block;
padding: 0.8em 1.2em;
text-decoration: none;
font-size: 1.1em;
font-family: 'Carme', Tahoma, Verdana, Arial;
color: #bde8a9;
-webkit-transition: all 0.1s ease-out;
-moz-transition: all 0.1s ease-out;
-ms-transition: all 0.1s ease-out;
-o-transition: all 0.1s ease-out;
transition: all 0.1s ease-out;
}
#mainnav-menu a:link, #mainnav-menu a:visited{
color: #bde8a9;
text-decoration: none;
}
#mainnav-menu a:hover {
color: #64c937;
background: #0088ff;
}
#mainnav-menu ul {
position: absolute;
display: none;
z-index: 99;
background: #0088ff;
}
#mainnav-menu ul li{
margin: 0;
}
#mainnav-menu ul a {
width: 250px;
width: 16rem;
padding: 0.7em 1.3em;
float: left;
font-weight: normal;
color: #fff;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
#mainnav-menu ul a:link, #mainnav-menu ul a:visited{
color: #fff;
font-size: 1.0em;
text-decoration: none;
}
#mainnav-menu li ul ul {
margin-left: 250px;
margin-left: 16rem;
}
#wrapper {
max-width: 1000px;
width: 92%;
margin: 0 auto 5em;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
background: #00F;
-moz-box-shadow: 0 0 10px #888;
-webkit-box-shadow: 0 0 10px#888;
box-shadow: 0 0 10px #888;
}
HTML:
<header id="header" class="container clearfix" role="banner">
<div id="logo">
</div>
</header>
<h3 id="mainnav-icon">Menu</h3><nav id="mainnav" class="container clearfix" role="navigation">
<ul id="mainnav-menu" class="menu"><li id="menu-item-62" class="menu-item menu-item-type-post_type menu-item-object-page current-menu-item page_item page-item-2 current_page_item menu-item-62"><a href="#">Home</a></li>
<li id="menu-item-63" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-63"><a href="#">About</a></li>
<li id="menu-item-65" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-65"><a href="#">Contact</a></li>
</ul> </nav>
</div>
jsfiddle:在这里
我的问题是,我无法使导航栏的左侧扩展。有任何想法吗?我很乐意欣赏。谢谢。
笔记:
我不想使用任何额外的图像,我只想在纯 css 中做到这一点。