html - 什么因素导致我的 Accordion 有空格?

标签 html css menu

我正在为我的 HTML/CSS 类(class)做我的期末元素。我正在尝试(可能过于雄心勃勃)创建一个可折叠的 Accordion 式菜单。我已经设法将它隐藏起来并且只显示悬停,但由于某种原因,有一个元素导致框之间有空格,我不确定如何在框中包含文本。提前感谢您的任何想法!

截图: How to remove the area with the red background?

编辑:抱歉第一次在这里发帖,不确定要发多少代码。

HTML代码

  

 @charset "utf-8";


/* HTML Styles */



/*Body Styles*/

html {
	background-image: url(../images/sushi_wallpaper.jpeg);

}



body { 
	display:block;
	width: 100%;
	max-width: 1040px;
	margin-left: auto;
	margin-right: auto;
	background-color: white;
	border: 7px solid rgb(149,54,0);
	border-top: none;
	border-bottom: none; /* BODY BORDER, RE-ADDRESS WITH COLORS */
	position: static;
	border-collapse: collapse;
}
	
	
/*Navigation Styles*/

nav {
	font-family: 'Times New Roman', serif;
	text-align: center;
}

ul {
	list-style-type: none;
	margin: 0;
	padding: 0;
}

nav.horizontalnavigation li {
/*BUTTON SIZES */	
	display: block;
	float: left;
	width: 25%;
	text-decoration: none;
	line-height: 2;
	padding-bottom: 1em;
}

nav.horizontalnavigation li a:hover {
	background-color:rgb(255,198,73);
}

/* COLLAPSE ABLE MENU */ 

ul.collapse {
	display: none;
}

 
a.accord:hover+ul.collapse, ul.collapse:hover {
	display: block;
	float: left;
	width: 100%;
} 



.collapse > .submenu  {
	width: 100%;
	background-color: red; }




ul.collapse li {
	width: 80%;
	float: right;
	border: none;
	line-height: initial;
} 

 nav.horizontalnavigation > ul > li:hover:nth-of-type(4):after {
	text-decoration: underline;
	content: #collapse;
	
} 

 nav.horizontalnavigation > ul > li:target {
	display: block;
} 

nav.horizontalnavigation a {
 /*"BUTTONS" STYLES HERE */	
	display: block;
	color: black;
	text-decoration: none;
	background-color: white;
	border: 3px solid rgb(149,54,0);
	box-shadow: 0 0 1em .3em rgb(255,198,73) inset;
	
}

/* Header Styles */
 
 h1 {
   font-family: 'Times New Roman', Times, serif;
   font-size: 2.2em;
   font-weight: normal;
   margin: 0.5em 0;
 }
 


/*Font Styles */

@font-face {
	font-family: speedingBrush;
	src: url("../fonts/SpeedingBrush.ttf") format("truetype");
}

cite {
	font-style: italic;
}

/* Paragraph Styles */

p {
	display:block;
	font-size: 1em;
	line-height: 1.375;
	text-indent: 8%;
}

	
/*Images Styles*/	
	
body > header > img.banner {
	display:block;
	width: 100%;
}	
	


/* DIV & Section Styles */

 

/*List Styles */



/*Footer Styles*/


footer {
	display: block;
	text-align: center;
	width: 100%;
	border: 2px solid rgb(149,54,0);
	line-height: 2;
	margin-top: 15em;
	clear: both;
	
}
<nav class="horizontalnavigation">
		<ul>
			<li><a href="sl_pr_table.html">Popular Types of Sushi</a></li>
			<li><a href="#">Where can I get sushi?</a></li>
			<li><a href="#">FREE Sushi Catalog</a></li>
			<li><a href="#" class="accord">Additional Resources</a>
				<ul class="collapse">
					<li class="submenu"><a href="#">WWWWWWWWWWWWWWW</a></li>
					<li class="submenu"><a href="#">WWWWWWWWWWWWWWWWWWWWWWWWW</a></li>
					<li class="submenu"><a href="#">WWWWWWWWWWWW</a></li>
				</ul>
			</li>
		</ul>
	</nav>

最佳答案

只需添加

ul.collapse li.submenu{
  padding: 0;
}

关于html - 什么因素导致我的 Accordion 有空格?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45390568/

相关文章:

html - 修复了 Bootstrap 导航栏中的搜索框

javascript - Slick slider 使用数据属性对带有幻灯片的导航项进行分组

JQuery 菜单打开但随后消失

c++ - 制作某种菜单时出现问题

html - CSS:让文本出现在我的 div 中的渐变之上

jquery - 显示一个 div 但隐藏所有其他 div 不起作用

jquery - swipeUp 或 swipeDown 在模拟移动平台的 google chrome 中无效

html - CSS 媒体查询的精确 NOT(逆)

php - 无法将下载的 HTML 模板集成到 wordpress 主题中

android - 根据 fragment 条件显示/隐藏菜单