What element is causing my accordion to have spaces? - html

I'm working on my final project for my HTML/CSS class. I'm trying to (potentially over ambitious) create a collapsible accordion style menu. I've managed to get it hid and only show up with a hover, but for some reason, there is an element causing the boxes to have spaces between them, and I'm unsure how to contain the text in the boxes. Thank you in advance for any ideas you have!
Screenshot:
How to remove the area with the red background?
EDIT: Sorry first time posting here, wasn't sure how much code to post.
HTML Code
#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>Popular Types of Sushi</li>
<li>Where can I get sushi?</li>
<li>FREE Sushi Catalog</li>
<li>Additional Resources
<ul class="collapse">
<li class="submenu">WWWWWWWWWWWWWWW</li>
<li class="submenu">WWWWWWWWWWWWWWWWWWWWWWWWW</li>
<li class="submenu">WWWWWWWWWWWW</li>
</ul>
</li>
</ul>
</nav>

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

Remove padding-bottom: 1em; and it will solve your issue.
nav.horizontalnavigation li {
/*BUTTON SIZES */
display: block;
float: left;
width: 25%;
text-decoration: none;
line-height: 2;
padding-bottom: 1em; // <----- This is causing the spacing
}

Related

Why is my dropdown not working correctly?

I am building a personal website, and want to get a dropdown menu working. So far the first part is working, but the second (dropdown in dropdown) isn't.
It is the "Alternate History" line that isn't showing up.
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333;
}
li {
float: left;
}
li a {
display: block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
/* Change the link color to #111 (black) on hover */
li a:hover {
background-color: #111;
}
#links img,
footer img,
li img,
h1 img,
h2 img,
h3 img,
p img,
.dropme img {
height: 1em;
}
footer {
clear: both;
text-align: center;
padding-top: 2em;
}
body {
max-width: 900px;
margin-left: auto;
margin-right: auto;
padding: 1em;
background: #111;
color: #eee;
}
html {
padding-bottom: 500px;
}
dt {
color: orange;
margin-top: 2px;
}
dd {
margin-bottom: 2px;
}
h1,
h2,
h3,
h4,
h5,
h6 {
text-align: center;
text-shadow: -1px 3px 3px rgba(0, 0, 0, 0.68);
}
h1 {
color: red;
}
h2 {
color: goldenrod;
}
h3 {
color: teal;
}
a {
color: lime;
text-decoration: none;
}
a:hover {
color: red;
}
.menubar li a {
display: block;
}
.menubar {
display: inline-block;
margin: 0;
padding: 0;
zoom: 1;
}
nav {
margin-left: auto;
margin-right: auto;
font-size: large;
text-align: center;
}
.menubar li {
display: block;
float: left;
width: 100px;
min-height: 1.5em;
background: #222;
border: #444 solid 2px;
padding: 3px;
margin: 4px;
}
.menubar li:hover {
background: #000;
}
.menubar a {
text-decoration: none;
}
.menubar li ul {
visibility: hidden;
position: absolute;
padding-top: 10px;
}
.menubar li:hover ul {
visibility: visible;
padding-left: 0;
margin-left: -7px;
}
.menubar li ul li {
float: none;
position: relative;
width: 150px;
text-align: left;
}
code {
color: green;
/* overflow-x: auto; */
}
/* pre { */
/* background: var(--color256); */
/* border: 1px solid var(--color8); */
/* border-radius: 4px; */
/* padding: 5px; */
/* display: block; */
/* align: center; */
/* max-width: 900px; */
/* /1* background: #1d2021; *1/ */
/* } */
<!DOCTYPE html>
<html lang="en">
<head>
<title>Smash Civilization's Homepage</title>
<link rel='stylesheet' type='text/css' href='style.css'>
<meta charset="utf-8" />
</head>
<body>
<nav>
<ul class="menubar">
<h1><big>Smash Civilization</big></h1>
<div id="links">
<div class="cat">
<li>Home</li>
<li>About</li>
<li>Literature
<ul>
<li>Category</li>
<ul>
<li>Alternate History</li>
</ul>
<li>Dewey Decimal</li>
</ul>
<li>Issues</li>
<li>Podcasts</li>
<li>Talks</li>
<li>Vision</li>
</div>
</div>
</ul>
</nav>
</body>
</html>
What do I need to fix to get this working correctly? Any help is most appreciated!

mobile screen showing large gaps inbetween menu items

My mobile menu has large gaps in between the list items, my code does not help me, can anyone else see something?
This is most likely due to px or some other screen-scaled metric not translating properly onto the mobile resolution.
I have tried unsuccessfully to upload a supporting image.
html, body
{
font-family: "Lato", sans-serif;
width: 100%;
height: auto; margin: 0;
}
.nav {
background-color: #3333FF;
width: 100%;
height: 40px;
line-height: 40px;
}
.menu {
font-family: Monserrat, sans-serif;
font-size: 18px;
color: white;
list-style-type: none;
padding: 0;
position: relative;
z-index: 1;
}
.menu a {
text-decoration: none;
color: #fff;
line-height: 40px; /* Line height 40px, not 40-px */
}
.menu ul li {
text-align: center;
display: inline;
padding: 10px;
width: 11.11%;
}
.menu li:visited, .menu li:active, .active, .menu li:hover
{
background: #0000EE;
color: #fff;
}
label {
margin: 0 14px 0 0;
font-size: 20px;
display: none;
}
#toggle {
display: none;
}
/* Show Hamburger */
#media screen and (max-width: 500px) {
label {
cursor: pointer;
display: block;
color: #fff;
}
.menu {
text-align: center;
width: 100%;
display: none;
}
.menu a {
display: block;
background-color: #999;
margin:0;
padding: 0;
}
#toggle:checked + .menu {
display: block;
}
} /* A finishing bracket was missing */

Responsive navigation links being pushed under navigation bar when browser is made smaller

I am trying to create a responsive website. I had a navigation bar on top of the page with links on the right and social media icons on the left. When I make the browser smaller it pushes the links under the navigation bar as if it was being pushed into another div.
I believe the social icons are causing the problem. They are two different div's inside multiple div's. If I remove the social icons it works but I would like to keep the social icons top left.
<body>
<div id="outerWrapper"> </div>
<div id="navWrapper">
<div id="navInnerWrapper">
<div id="topSocials">
<img alt="facebook icon" src="images/fb_social.png">
<img alt="linkedin icon" src="images/linkedin_social.png">
</div>
<div id="navBar">
<ul>
<li>About</li>
<li>Our Work</li>
<li>Contact Us</li>
</ul>
</div>
</div>
#outerWrapper {
width: 100%;
height: auto;
display: block;
position: relative;
color: #333333;
font-family: "Gill Sans", "Gill Sans MT", "Myriad Pro", "DejaVu
Sans Condensed", Helvetica, Arial, sans-serif;
font-size: 14px;
text-align: left;
line-height: 20px;
}
#navWrapper {
width: 100%;
height: 45px;
display: block;
padding-top: 10px;
padding-bottom: 10px;
position: relative;
clear: both;
border-bottom: 3px solid #000000;
background-color: #9FA2B2;
}
#navInnerWrapper {
width: auto;
height: auto;
display: block;
margin-left: auto;
margin-right: auto;
position: relative;
clear: both;
padding-right: 200px;
}
#topSocials {
width: 231px;
display: block;
position: relative;
float: left;
height: auto;
padding-top: 5px;
padding-left: 50px;
}
#navBar {
width: 600px;
display: block;
position: relative;
float: right;
height: auto;
color: #FFFFFF;
text-align: right;
text-transform: uppercase;
}
ul {
list-style-type: none;
}
ul li {
display: inline;
padding-left: 40px;
}
#navBar a:link {color: #16262E; text-decoration: none; }
#navBar a:visited {color: #16262E; text-decoration: none; }
#navBar a:hover {color: #FFFFFF; text-decoration: none; }
#navBar a:active {color: #16262E; text-decoration: none; }
This is what it looks like when I make the browser smaller.
https://imgur.com/a/BLSilIp
Want the navigation to be responsive with links on the right and social icons on the left.
You have a very bad code. See how many properties I fixed and added to you in CSS. Learn better.
#navWrapper {
width: 100%;
/* height: 45px; */
/* display: block; */
/* padding-top: 10px; */
/* padding-bottom: 10px; */
/* position: relative; */
/* clear: both; */
border-bottom: 3px solid #000000;
background-color: #9FA2B2;
box-sizing: border-box;
}
#navInnerWrapper {
/* width: auto; */
/* height: auto; */
/* display: block; */
/* margin-left: auto; */
/* margin-right: auto; */
/* position: relative; */
/* clear: both; */
/* padding-right: 200px; */
/* padding: 20px 0; */
display: flex;
flex-flow: wrap;
justify-content: space-between;
align-items: center;
}
#topSocials {
/* width: 231px; */
/* display: block; */
/* position: relative; */
/* float: left; */
/* height: auto; */
/* padding-top: 5px; */
/* padding-left: 50px; */
display: flex;
flex-direction: row;
padding: 10px;
}
#topSocials a {
margin-right: 10px;
}
#navBar {
/* width: 600px; */
/* display: block; */
/* position: relative; */
/* float: right; */
/* height: auto; */
/* color: #FFFFFF; */
/* text-align: right; */
text-transform: uppercase;
padding: 10px;
}
ul {
list-style-type: none;
display: flex;
flex-flow: wrap;
padding: 0;
margin: 0;
}
ul li {
/* display: inline; */
/* padding-left: 40px; */
margin-left: 20px;
}
ul li:first-child {
margin-left: 0px;
}
#navBar a:link {
color: #16262E;
text-decoration: none;
}
#navBar a:visited {
color: #16262E;
text-decoration: none;
}
#navBar a:hover {
color: #FFFFFF;
text-decoration: none;
}
#navBar a:active {
color: #16262E;
text-decoration: none;
}
<div id="navWrapper">
<div id="navInnerWrapper">
<div id="topSocials">
<img alt="facebook icon" src="images/fb_social.png">
<img alt="linkedin icon" src="images/linkedin_social.png">
</div>
<div id="navBar">
<ul>
<li>About</li>
<li>Our Work</li>
<li>Contact Us</li>
</ul>
</div>
</div>

Heading changes font and position when not in full screen

I am making a website using HTML and CSS and the heading displays fine in full screen but when I make it half the screen size the header (h1) changes to the default font and aligns to the left instead of the center as it should.
Here is my HTML code:
<!DOCTYPE html>
<html>
<head>
<link href="https://fonts.googleapis.com/css?family=Inconsolata" rel="stylesheet">
<title>Home page</title>
<link type="text/css" rel="stylesheet"
href="css/filesheet1.css"/>
</head>
<body>
<nav>
<ul>
<li>Home page</li>
<li>About us</li>
<li>Our songs</li>
<li>See us play</li>
<li>Contact us</li>
<li>Merchandise</li>
<li>Playing a concert</li>
</ul>
</nav>
<h1>Home</h1>
</body>
</html>
Here is my CSS code (sorry if there's a lot as I have no idea whats causing this issue I have put it all there):
/* set sizing to border box method */
html {
box-sizing: border-box;
}
*, *:before, *:after {
box-sizing: inherit;
}
/* set maximum and minimum widths for the body and centre within the viewport */
body {
text-align: center;
border: solid;
border-radius: 15px;
border-color: #CACFD2;
box-shadow: 0 0 100px 0 #888888;
background-color: #CACFD2;
font-family: 'Inconsolata', monospace;
margin-left: auto;
margin-right: auto;
max-width: 1024px;
min-width: 256px;
padding-top: 8px;
padding-bottom: 24px;
padding-left: 24px;
padding-right: 24px;
}
html, html body{
height: 100%;
}
html{
background-color: white;
}
/* header */
header{
}
header p {
float: left;
font-size: 16px;
font-weight: bold;
margin-top: 0px;
}
header h1 {
font-size: 16px;
text-align: center;
}
/* the menu */
nav ul {
text-align: center;
list-style-type: none;
background-color: none;
border: none;
font-family: 'Inconsolata', monospace;
font-weight: 400;
padding: 16px;
}
nav ul li {
display: inline;
border-right: 2px solid #111111;
padding-right: 8px;
padding-left: 8px;
}
nav ul li:last-child {
border-right: none;
}
nav ul li a {
text-decoration: none;
color: #111111;
}
nav li.selected{
color: #606060;
}
nav ul li a:hover {
font-weight: 900;
}
/* biographies */
section {
background-color: #FFFFFF;
margin-bottom: 24px;
min-height: 320px;
padding-left: 24px;
padding-right: 24px;
}
/* the aside */
aside {
}
/* footer */
footer {
}
footer p.copyright {
float: left;
margin-top: 0px;
}
footer p.contact {
text-align: right;
}
/* small images are set to 200px in height */
img.small {
float: left;
height: 200px;
margin-bottom: 24px;
margin-right: 24px;
}
/* medium images can be 50% of the container element’s width, up to 360px */
img.medium {
max-width: 360x;
width: 50%;
}
/* large images are 100% of the container element’s width */
img.large {
width: 100%;
}
/* add the same style of border to the elements which are to have borders */
section, img {
border: 2px solid #B1B1B1;
border-radius: 16px;
}
/* the bits that are specific to a wide viewport (over 56em) */
#media{
min-width: 900px
}
article {
float: left;
width: 66%;
}
aside {
float: left;
padding-left: 24px;
width: 34%;
}
footer {
clear: both;
}
h1{
text-align: center;
font-family: 'Inconsolata', monospace;
}
/* Styles go here */
/* set sizing to border box method */
html {
box-sizing: border-box;
}
*, *:before, *:after {
box-sizing: inherit;
}
/* set maximum and minimum widths for the body and centre within the viewport */
body {
text-align: center;
border: solid;
border-radius: 15px;
border-color: #CACFD2;
box-shadow: 0 0 100px 0 #888888;
background-color: #CACFD2;
font-family: 'Inconsolata', monospace;
margin-left: auto;
margin-right: auto;
max-width: 1024px;
min-width: 256px;
padding-top: 8px;
padding-bottom: 24px;
padding-left: 24px;
padding-right: 24px;
}
html, html body{
height: 100%;
}
html{
background-color: white;
}
/* header */
header{
}
header p {
float: left;
font-size: 16px;
font-weight: bold;
margin-top: 0px;
}
header h1 {
font-size: 16px;
text-align: center;
}
/* the menu */
nav ul {
text-align: center;
list-style-type: none;
background-color: none;
border: none;
font-family: 'Inconsolata', monospace;
font-weight: 400;
padding: 16px;
}
nav ul li {
display: inline;
border-right: 2px solid #111111;
padding-right: 8px;
padding-left: 8px;
}
nav ul li:last-child {
border-right: none;
}
nav ul li a {
text-decoration: none;
color: #111111;
}
nav li.selected{
color: #606060;
}
nav ul li a:hover {
font-weight: 900;
}
/* biographies */
section {
background-color: #FFFFFF;
margin-bottom: 24px;
min-height: 320px;
padding-left: 24px;
padding-right: 24px;
}
/* the aside */
aside {
}
/* footer */
footer {
}
footer p.copyright {
float: left;
margin-top: 0px;
}
footer p.contact {
text-align: right;
}
/* small images are set to 200px in height */
img.small {
float: left;
height: 200px;
margin-bottom: 24px;
margin-right: 24px;
}
/* medium images can be 50% of the container element’s width, up to 360px */
img.medium {
max-width: 360px;
width: 50%;
}
/* large images are 100% of the container element’s width */
img.large {
width: 100%;
}
/* add the same style of border to the elements which are to have borders */
section, img {
border: 2px solid #B1B1B1;
border-radius: 16px;
}
/* the bits that are specific to a wide viewport (over 56em) */
#media all and (min-width: 900px) {
}
article {
float: left;
width: 66%;
}
aside {
float: left;
padding-left: 24px;
width: 34%;
}
footer {
clear: both;
}
h1{
text-align: center;
font-family: 'Inconsolata', monospace;
}
<!DOCTYPE html>
<html>
<head>
<link href="https://fonts.googleapis.com/css?family=Inconsolata" rel="stylesheet">
<title>Home page</title>
<link type="text/css" rel="stylesheet"
href="style.css"/>
</head>
<body>
<nav>
<ul>
<li>Home page</li>
<li>About us</li>
<li>Our songs</li>
<li>See us play</li>
<li>Contact us</li>
<li>Merchandise</li>
<li>Playing a concert</li>
</ul>
</nav>
<h1>Home</h1>
</body>
</html>
This should work for you now.

Website paragraph box below navigation bar

I'm currently writing a website from scratch and I'm having some problems with my css and html. I not sure how to create a space between my navigation bar and my content box.
Here is my html:
http://pastebin.com/cTVCx0gm
and my css:
http://pastebin.com/w61aTmHv
Since I'm a novice programmer, I'm not really sure what I'm doing wrong...
Thanks!
All you need to do is change your "li" class to this:
li
{
display:inline-block;
}
I've created this fiddle here so you can see the output. You can move the center bar left and right to see the behavior.
http://jsfiddle.net/ninja1/ALKPP/
try this
Demo
ul {
list-style-type: none;
margin: 0;
padding: 0;
width: 100%;
}
li {
display: inline;
float: left;
}
a {
display: block;
width: 150px;
height: 30px;
background-color: #024c68;
text-align: center;
padding: 10px;
font-size: 20px;
display: inline;
}
a:link {
color: #ffffff;
text-decoration: none;
font-family: verdana;
} /* unvisited link */
a:visited {
color: #ffffff;
text-decoration: none;
font-family: verdana;
} /* visited link */
a:hover {
color: #ffffff;
text-decoration: none;
font-family: verdana;
background: #226078;
} /* mouse over link */
a:active {
text-decoration: underline;
text-decoration: none;
font-family: verdana;
} /* selected link */
/*this is the body css*/
body {
background-color: #62b1d0;
}
div.box {
background-color: #99CCFF;
border: 5px solid #99CCFF;
clear: left;
margin: 9px 0 0 0;
padding: 8px 10px;
width: 900px;
}
.clrboth {
clear: both;
}