我的子菜单不会出现在右侧

时间:2016-06-17 22:32:28

标签: html css

我有一个居中的水平导航栏。其中三个链接有子菜单,其中两个有子子菜单。我不能让子子菜单出现在右边。谁能帮助我呢?

  /* http://meyerweb.com/eric/tools/css/reset/ 
       v2.0 | 20110126
       License: none (public domain)
    */

html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,
var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td,article,aside,canvas,details,embed,figure,figcaption,footer,header,
hgroup,menu,nav,output,ruby,section,summary,time,mark,audio,video {
  margin: 0;
  padding: 0;
  border: 0;
  font-size: 100%;
  font: inherit;
  vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */

article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section {
  display: block;
}
body {
  line-height: 1;
}
ol,
ul {
  list-style: none;
}
blockquote,
q {
  quotes: none;
}
blockquote:before,
blockquote:after,
q:before,
q:after {
  content: '';
  content: none;
}
table {
  border-collapse: collapse;
  border-spacing: 0;
}
/* ^Reset style. DO NOT DELETE! */

/*-------------------------------------------------------------------------*/

body {
  background-color: #254117;
  color: white;
  width: 100%;
  /*max-width: 960px;*/
  margin: 0 auto;
  margin-top: 12em;
  /* ADDED TO MAKE HEADER FIXED*/
}

nav {
  width: 99%;
  margin: 20px 0.5%;
  clear: both;
}
nav ul {
  list-style: none;
  overflow: auto;
}
nav ul li {
  float: left;
  width: 16.6666%;
}

nav ul li a {
  text-align: center;
  font-family: cursive;
  padding: 8px 0;
  display: block;
  /*width: 97.5%;*/
  border-top: 4px solid #FFEE2E;
  border-right: 4px solid #E5C000;
  border-bottom: 4px solid #E5C000;
  border-left: 4px solid #FFEE2E;
  background-color: #FCD717;
  font-size: 1.5em;
}
nav ul li a,
nav ul li a:focus,
nav ul li a:visited,
nav ul li a:hover,
nav ul li a:active {
  text-decoration: none;
  color: #0000EE;
}
nav ul li a:hover,
nav ul li a:active {
  background-color: #FFE424;
  border-top: 4px solid #E5C000;
  border-right: 4px solid #FFE424;
  border-bottom: 4px solid #FFE424;
  border-left: 4px solid #E5C000;
  border-radius: 0;
}
nav ul li:first-child a {
  border-top-left-radius: 8px;
  border-bottom-left-radius: 8px;
}
nav > ul li:last-child a {
  border-top-right-radius: 8px;
  border-bottom-right-radius: 8px;
}
/* ^NAVIGATION BAR - LEVEL 1 */

/*-------------------------------------------------------------------------*/

nav li > ul li {
  display: block;
  width: 99%;
  position: relative;
}
nav li > ul {
  display: none;
  width: inherit;
}
nav li > ul li:first-child a {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}
nav li > ul li:last-child a {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}
nav li > ul:last-child a {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}
nav li:hover > ul {
  display: block;
  position: absolute;
}

/* ^NAVIGATION BAR - LEVEL 2 */
/*-------------------------------------------------------------------------*/

nav li > ul li > ul li{
  display: block;
  position: relative;
  width: 99%;
}

nav li > ul li > ul{
  display: none;
  width: 100%;
/*  position: relative;
*/  top: 0;
  left: 100%;
}

nav li:hover ul li:hover ul{
  display: block;
  position: absolute;
}
<nav>
	<ul>
		<li> <a href="BonleeGrownFarm2.html"> Home </a> </li>
		<li> <a href="OurStory.html"> Our Story </a> </li>
		<li>
			<a href="WheretoFindUs.html"> Where to Find Us </a>
			<ul>
				<li> <a href="Market1.html"> Market1 </a> </li>
				<li> <a href="Market2.html"> Market2 </a> </li>
				<li> <a href="Market3.html"> Market3 </a> </li>
				<li> <a href="Market4.html"> Market4 </a> </li>
			</ul>
		</li>
		<li>
			<a href="FromOurFarm.html"> From Our Farm </a>
			<ul>
				<li>
					<a href="javascript:;"> Fall </a>
					<ul>
						<li> <a href="Plant1.html"> Plant1 </a> </li>
						<li> <a href="Plant2.html"> Plant2 </a> </li>
						<li> <a href="Plant3.html"> Plant3 </a> </li>
						<li> <a href="Plant4.html"> Plant4 </a> </li>
						<li> <a href="Plant5.html"> Plant5 </a> </li>
						<li> <a href="Plant6.html"> Plant6 </a> </li>
						<li> <a href="Plant7.html"> Plant7 </a> </li>
						<li> <a href="Plant8.html"> Plant8 </a> </li>
						<li> <a href="Plant9.html"> Plant9 </a> </li>
						<li> <a href="Plant10.html"> Plant10 </a> </li>
					</ul>
				</li>
				<li>
					<a href="javascript:;"> Winter </a>
					<ul>
						<li> <a href="Plant1.html"> Plant1 </a> </li>
						<li> <a href="Plant2.html"> Plant2 </a> </li>
						<li> <a href="Plant3.html"> Plant3 </a> </li>
						<li> <a href="Plant4.html"> Plant4 </a> </li>
						<li> <a href="Plant5.html"> Plant5 </a> </li>
						<li> <a href="Plant6.html"> Plant6 </a> </li>
						<li> <a href="Plant7.html"> Plant7 </a> </li>
						<li> <a href="Plant8.html"> Plant8 </a> </li>
						<li> <a href="Plant9.html"> Plant9 </a> </li>
						<li> <a href="Plant10.html"> Plant10 </a> </li>
					</ul>
				</li>
				<li> 
					<a href="javascript:;"> Spring </a>
					<ul>
						<li> <a href="Plant1.html"> Plant1 </a> </li>
						<li> <a href="Plant2.html"> Plant2 </a> </li>
						<li> <a href="Plant3.html"> Plant3 </a> </li>
						<li> <a href="Plant4.html"> Plant4 </a> </li>
						<li> <a href="Plant5.html"> Plant5 </a> </li>
						<li> <a href="Plant6.html"> Plant6 </a> </li>
						<li> <a href="Plant7.html"> Plant7 </a> </li>
						<li> <a href="Plant8.html"> Plant8 </a> </li>
						<li> <a href="Plant9.html"> Plant9 </a> </li>
						<li> <a href="Plant10.html"> Plant10 </a> </li>
					</ul>
				</li>
				<li> 
					<a href="javascript:;"> Summer </a>
					<ul>
						<li> <a href="Plant1.html"> Plant1 </a> </li>
						<li> <a href="Plant2.html"> Plant2 </a> </li>
						<li> <a href="Plant3.html"> Plant3 </a> </li>
						<li> <a href="Plant4.html"> Plant4 </a> </li>
						<li> <a href="Plant5.html"> Plant5 </a> </li>
						<li> <a href="Plant6.html"> Plant6 </a> </li>
						<li> <a href="Plant7.html"> Plant7 </a> </li>
						<li> <a href="Plant8.html"> Plant8 </a> </li>
						<li> <a href="Plant9.html"> Plant9 </a> </li>
						<li> <a href="Plant10.html"> Plant10 </a> </li>
					</ul>
				</li>
			</ul>
		</li>
		<li>
			<a href="FromOurKitchen.html"> From Our Kitchen </a>
			<ul>
				<li>
					<a href="javascript:;"> Jam </a>    
					<ul>
						<li> <a href="Jam1.html"> Jam1 </a> </li>
						<li> <a href="Jam2.html"> Jam2 </a> </li>
						<li> <a href="Jam3.html"> Jam3 </a> </li>
						<li> <a href="Jam4.html"> Jam4 </a> </li>
						<li> <a href="Jam5.html"> Jam5 </a> </li>
						<li> <a href="Jam6.html"> Jam6 </a> </li>
						<li> <a href="Jam7.html"> Jam7 </a> </li>
						<li> <a href="Jam8.html"> Jam8 </a> </li>
						<li> <a href="Jam9.html"> Jam9 </a> </li>
						<li> <a href="Jam10.html"> Jam10 </a> </li>
					</ul>
				</li>
				<li>
					<a href="javascript:;"> Jelly </a>
					<ul>
						<li> <a href="Jam1.html"> Jam1 </a> </li>
						<li> <a href="Jam2.html"> Jam2 </a> </li>
						<li> <a href="Jam3.html"> Jam3 </a> </li>
						<li> <a href="Jam4.html"> Jam4 </a> </li>
						<li> <a href="Jam5.html"> Jam5 </a> </li>
						<li> <a href="Jam6.html"> Jam6 </a> </li>
						<li> <a href="Jam7.html"> Jam7 </a> </li>
						<li> <a href="Jam8.html"> Jam8 </a> </li>
						<li> <a href="Jam9.html"> Jam9 </a> </li>
						<li> <a href="Jam10.html"> Jam10 </a> </li>
					</ul>
				</li>
				<li>
					<a href="javascript:;"> Relish </a>
					<ul>
						<li> <a href="Jam1.html"> Jam1 </a> </li>
						<li> <a href="Jam2.html"> Jam2 </a> </li>
						<li> <a href="Jam3.html"> Jam3 </a> </li>
						<li> <a href="Jam4.html"> Jam4 </a> </li>
						<li> <a href="Jam5.html"> Jam5 </a> </li>
						<li> <a href="Jam6.html"> Jam6 </a> </li>
						<li> <a href="Jam7.html"> Jam7 </a> </li>
						<li> <a href="Jam8.html"> Jam8 </a> </li>
						<li> <a href="Jam9.html"> Jam9 </a> </li>
						<li> <a href="Jam10.html"> Jam10 </a> </li>
					</ul>
				</li>
				<li>
					<a href="javascript:;"> Pickled </a>    
					<ul>
						<li> <a href="Jam1.html"> Jam1 </a> </li>
						<li> <a href="Jam2.html"> Jam2 </a> </li>
						<li> <a href="Jam3.html"> Jam3 </a> </li>
						<li> <a href="Jam4.html"> Jam4 </a> </li>
						<li> <a href="Jam5.html"> Jam5 </a> </li>
						<li> <a href="Jam6.html"> Jam6 </a> </li>
						<li> <a href="Jam7.html"> Jam7 </a> </li>
						<li> <a href="Jam8.html"> Jam8 </a> </li>
						<li> <a href="Jam9.html"> Jam9 </a> </li>
						<li> <a href="Jam10.html"> Jam10 </a> </li>
					</ul>
				</li>
				<li>
					<a href="javascript:;"> Vinegar</a> 
					<ul>
						<li> <a href="Jam1.html"> Jam1 </a> </li>
						<li> <a href="Jam2.html"> Jam2 </a> </li>
						<li> <a href="Jam3.html"> Jam3 </a> </li>
						<li> <a href="Jam4.html"> Jam4 </a> </li>
						<li> <a href="Jam5.html"> Jam5 </a> </li>
						<li> <a href="Jam6.html"> Jam6 </a> </li>
						<li> <a href="Jam7.html"> Jam7 </a> </li>
						<li> <a href="Jam8.html"> Jam8 </a> </li>
						<li> <a href="Jam9.html"> Jam9 </a> </li>
						<li> <a href="Jam10.html"> Jam10 </a> </li>
					</ul>
				</li>
			</ul>
		</li>
		<li> <a href="CarolinaBabe.html"> Carolina Babe </a> </li>
	</ul>
</nav>

1 个答案:

答案 0 :(得分:1)

只需删除嵌套列表的overflow: auto

nav ul {
    list-style: none;
    overflow: auto; /* <-- REMOVE */
}

这是Fiddle,删除了身体上边距。