Need a basic submenu for my CSS navigation - css

So disregarding styling and everything else, all I would like is for a sub menu to appear for some of my navigation selections.
Right now I have a basic list that I made on my own using an online tutorial. Afterwards though, after searching through the web, I still have not found a submenu navigation that is close to my code or understanding.
This is my html code:
<div class="navigation">
<li>
<h2>Services</h2>
</li>
<li>
<h2>Store</h2> </l
<li>Photoshop</li>
<li>Illustrator</li>
<li>Web Design</li>
</li>
</nav>
</div>
<div class="navigation blue">
<li>
<a href="https://www.facebook.com/pages/Argano-Computer-Services/268377233227887?fref=ts">
<h2>Facebook</h2>
</a></li></div><a href="https://www.facebook.com/pages/Argano-Computer-Services/268377233227887?fref=ts">
</a>
<div class="navigation orange">
<li>
<a href="http://www.bing.com/maps/default.aspx?v=2&pc=FACEBK&mid=8100&rtp=adr.~pos.35.195859_-106.672877_Argano+Computer+Services_10009+Clearwater+Court%2C+Albuquerque%2C+New+Mexico&cp=35.195859~-106.672877&lvl=16&sty=r&rtop=0~0~0~&mode=D&FORM=FBKPL1&mkt=en-US" target="_blank">
<h2>Locate</h2>
</a>
</li>
</div>
<div class="navigation green">
<li>
<h2>Feedback</h2>
</li>
</div>
<div class="navigation purple">
<li>
<h2>About</h2>
</li>
</div>
</div>
</div>
this is my css:
<div class="navigation">
<li>
<h2>Services</h2>
</li>
<li>
<h2>Store</h2> </l
<li>Photoshop</li>
<li>Illustrator</li>
<li>Web Design</li>
</li>
</nav>
</div>
<div class="navigation blue">
<li>
<a href="https://www.facebook.com/pages/Argano-Computer-Services/268377233227887?fref=ts">
<h2>Facebook</h2>
</a></li></div><a href="https://www.facebook.com/pages/Argano-Computer-Services/268377233227887?fref=ts">
</a>
<div class="navigation orange">
<li>
<a href="http://www.bing.com/maps/default.aspx?v=2&pc=FACEBK&mid=8100&rtp=adr.~pos.35.195859_-106.672877_Argano+Computer+Services_10009+Clearwater+Court%2C+Albuquerque%2C+New+Mexico&cp=35.195859~-106.672877&lvl=16&sty=r&rtop=0~0~0~&mode=D&FORM=FBKPL1&mkt=en-US" target="_blank">
<h2>Locate</h2>
</a>
</li>
</div>
<div class="navigation green">
<li>
<h2>Feedback</h2>
</li>
</div>
<div class="navigation purple">
<li>
<h2>About</h2>
</li>
</div>
</div>
</div>
any suggestions?

Simple submenu for you:
<ul id="submenu">
<li>Home</li>
<li>About</li>
<li>Team</li>
</ul>
<style>
*, *:before, *:after {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
zoom: 1;
}
#submenu {
width: 200px;
background: #eee;
padding: 10px;
}
#submenu li{
margin: 0;
margin-bottom: 10px;
position: relative;
text-align: center;
font-weight: bold;
color: #fff !important;
line-height: 1 !important;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
white-space: nowrap;
border: none;
cursor: pointer;
display: inline-block;
vertical-align: middle;
zoom: 1;
border-radius: 3px;
-webkit-font-smoothing: antialiased;
background-color: #77cc6d;
text-shadow: 0 1px 0 rgba(0,0,0,0.15);
font-size: 15px;
padding: 12px 12px 12px 12px;
box-shadow: 0 3px 0 0 #53994b;
width: 100%;
}
#submenu li:active, #submenu li:focus{
box-shadow: 0 1px 0 0 #53994b;
top: 2px;
}
#submenu li:last-child{
margin-bottom: 0px;
}
</style>
JSFiddle: http://jsfiddle.net/aLggP/1/

Related

I am trying to add margins to the main content area, why is it not working?

I'm trying to add margin-top to the footer but it's not working, any ideas why?
body {
font-family: "Heebo", sans-serif;
}
h1,
h2,
h3,
h4,
h5,
h6 {
color: #000000;
font-family: Heebo, sans-serif;
}
span,
p {
color: #000000;
font-family: "Heebo", sans-serif;
font-size: 18px;
letter-spacing: 0.54px;
line-height: 30px;
}
a {
color: inherit;
font-family: "Heebo", sans-serif;
font-size: 18px;
text-decoration: none;
}
/*
* Padding X axis
*/
.px-100 {
padding-right: 100px;
padding-left: 100px;
}
.px-200 {
padding-right: 200px;
padding-left: 200px;
}
/*
* Padding Y axis
*/
.py-100 {
padding-top: 100px;
padding-bottom: 100px;
}
/*
* Header
*/
#header {
position: relative;
z-index: 1000;
background-color: #f1eeea;
}
#header .container-fluid .row {
height: 100px;
}
.language-switcher,
#menu > .menu {
list-style-type: none;
margin: 0;
padding: 0;
}
#menu > .menu {
margin-right: 65px;
}
#menu > .menu li {
font-size: 20px;
}
#menu > .menu li:not(:last-child) {
margin-right: 45px;
}
.language-switcher {
margin-right: 30px;
}
.language-switcher li {
color: #2e2e2e;
font-size: 20px;
}
.language-switcher li:not(:last-child) {
margin-left: 5px;
}
.language-switcher li:not(:last-child)::before {
content: "/";
}
.social-icons {
list-style-type: none;
margin: 0;
padding: 0;
}
.social-icons a:not(:last-child) {
margin-right: 15px;
}
/*
* Footer
*/
#footer {
background-color: #2e2e2e;
}
#footer p {
color: white;
font-size: 20px;
letter-spacing: 0;
line-height: 30px;
}
#footer p.credit {
color: white;
font-size: 25px;
letter-spacing: 0;
line-height: 30px;
}
#footer-bottom {
border-top: 1px solid #ececec;
}
#footer-bottom a,
#footer-bottom p {
color: white;
font-size: 18px;
letter-spacing: 0;
line-height: 27px;
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.2.0/css/bootstrap.min.css" integrity="sha512-XWTTruHZEYJsxV3W/lSXG1n3Q39YIWOstqvmFsdNEEQfHoZ6vm6E9GK2OrF6DSJSpIbRbi+Nn0WDPID9O7xB2Q==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<header id="header" role="banner">
<div class="container-fluid">
<div class="row align-items-center px-100">
<div class="col d-flex align-items-center justify-content-start">
<nav id="menu" class="" role="navigation" itemscope="" itemtype="https://schema.org/SiteNavigationElement">
<ul id="menu-%d7%aa%d7%a4%d7%a8%d7%99%d7%98-%d7%a8%d7%90%d7%a9%d7%99" class="menu d-flex align-items-center">
<li id="menu-item-68" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-68"><span itemprop="name">Item 2</span></li>
<li id="menu-item-69" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-69"><span itemprop="name">Item 1</span></li>
</ul>
</nav>
<img src="/wp-content/uploads/2022/06/icon-search.svg" id="open-search" alt="Search" data-bs-toggle="modal" data-bs-target="#popup-search">
</div>
<div class="col col-lg-2">
<div class="site-logo text-center">
<img width="113" height="60" src="/wp-content/uploads/2022/06/logo.png" class="custom-logo" alt="Logo">
</div>
</div>
<div class="col d-flex justify-content-end">
<ul class="language-switcher d-flex flex-row-reverse align-items-center">
<li class="lang-item lang-item-3 lang-item-en lang-item-first">
English
</li>
<li class="lang-item lang-item-6 lang-item-he current-lang">
עברית
</li>
</ul>
<ul class="social-icons d-flex align-items-center">
<a href="https://www.facebook.com/" target="_blank">
<img src="/wp-content/uploads/2022/06/icon-facebook.svg" alt="">
</a>
<a href="https://www.youtube.com/" target="_blank">
<img src="/wp-content/uploads/2022/06/icon-youtube.svg" alt="">
</a>
</ul>
</div>
</div>
</div>
</header>
<main>
Why is this text close to the footer if there is margin top on the footer?
</main>
<footer id="footer" class="mt-5">
<div class="container-fluid">
<div class="" id="footer-top">
<div class="row g-5 py-5">
<div class="col">
<div class="site-logo text-center">
<a href="https://example.com" class="custom-logo-link" rel="home" aria-current=" aria-current=" page""="">
<img src="/wp-content/uploads/2022/06/logo.png" alt="logo">
</a>
</div>
<p class="site-title text-center mb-0 mt-4"><strong>1</strong></p>
<p class="site-description text-center my-0">1</p>
</div>
<div class="col">
<p class="credit mb-0">1<br><strong>1</strong></p>
</div>
<div class="col">
<p class="mb-0"><strong>1:</strong> 1</p>
<p class="mb-0"><strong>2:</strong> 2</p>
</div>
<div class="col">
<p class="mb-0"><strong>1</strong></p>
<p class="mb-0"><strong>2:</strong> 2</p>
<p class="mb-0"><strong>3:</strong> 3</p>
</div>
<div class="col">
<p><strong>4:</strong></p>
<ul class="social-icons-list list-unstyled list-inline">
<li class="list-inline-item px-1">
<a href="https://www.facebook.com/" target="_blank">
<img src="/wp-content/uploads/2022/07/icon-facebook-white.svg" alt="">
</a>
</li>
<li class="list-inline-item px-1">
<a href="https://www.youtube.com/" target="_blank">
<img src="/wp-content/uploads/2022/07/icon-youtube-white.svg" alt="">
</a>
</li>
</ul>
</div>
</div>
</div>
<div class="" id="footer-bottom">
<div class="row py-4">
<div class="col">
<p class="text-center mb-0">1 1 | 2 2</p>
</div>
</div>
</div>
</div>
</footer>
Thanks!

Messed up my code trying to implement flexbox

So I was trying to implement flexbox into my container and it got messed up. I want the text to go beneath the circles, spaced and centered neatly and have it done via flexbox please. I am so lost in this code that I cannot figure this out, any help is greatly appreciated. It says I need t add more details but I can't think of any so this is just type.
.bottom__container {
background-color:rgba(255, 236, 0, 0.7);
text-align: center;
margin:0;
padding: 8px;
color: black;
font-family: 'Kalam', cursive;
font-weight: bolder;
font-size: 1.5rem;
}
.bottom__container li {
list-style: none;
display: inline-block;
padding: 32px;
}
.btm-container__why {
font-size:2.5rem;
margin:0;
}
.btm-container__depends {
font-size: small;
text-align: right;
font-family: initial;
}
.circle {
width: 128px;
height: 128px;
border: 2px solid #424242;
border-radius: 50%;
margin: auto;
background-color: white;
}
.icon {
margin-top: 20%;
}
<section class="btm-containers">
<section id="scroll" class="bottom__container">
<div>
<h1 class="btm-container__why">Why Choose Us?</h1>
<ul>
<li class="lists">
<div class="circle">
<div class="icon"><i class="fa fa-users fa-3x" aria-hidden="true"></i></div>
</div>
<p>Thousands of Clients</p>
</li>
<li class="lists">
<div class="circle">
<div class="icon"><i class="fa fa-handshake-o fa-3x" aria-hidden="true"></i></div>
</div>
<p>Online/In-person Consultations*</p>
</li>
<li class="lists">
<div class="circle">
<div class="icon"><i class="fas fa-directions fa-3x"></i></div>
</div>
<p>Guided Tours*</p>
</li>
<li>
<div class="circle">
<div class="icon"><i class="fa fa-building-o fa-3x" aria-hidden="true"></i></div>
</div>
<p>Affordable Rent!*</p>
</li>
</ul>
<p class="btm-container__depends">*Depends on service purchased.</p>
</div>
</section>
Is there a reason why you put "lists" as a class for both ul and li? and then in your CSS you also selected "lists li". Put another class or change it for one of them, and then you should be able to center it.
Try cleaning up your code first. You have various mistakes such as
<li class="lists">
<div class="circle">
<div class="icon"><i class="fas fa-directions fa-3x"></i></div>
<p>Guided Tours*</p>
</div>
</li class="lists">
<li>
and I think you'd have an easier time debugging if you had it organized.
The problem is with the class for both ul and li (lists) also with padding here is your desired result:
<section id="scroll" class="btm-container">
<div>
<h1 class="btm-container__why">Why Choose Us?</h1>
<ul class="lists">
<li class="list-item">
<div class="position-relative d-flex flex-column align-items-center justify-content-center">
<div class="circle icon"><i class="fa fa-users fa-3x" aria-hidden="true"></i></div>
<p>Thousands of Clients</p>
</div>
</li>
<li class="list-item">
<div class="position-relative d-flex flex-column align-items-center justify-content-center">
<div class="circle icon"><i class="fa fa-handshake-o fa-3x" aria-hidden="true"></i></div>
<p>Online/In-person Consultations*</p>
</div>
</li>
<li class="list-item">
<div class="position-relative d-flex flex-column align-items-center justify-content-center">
<div class="circle icon"><i class="fas fa-directions fa-3x"></i></div>
<p>Guided Tours*</p>
</div>
</li>
<li class="list-item">
<div class="position-relative d-flex flex-column align-items-center justify-content-center">
<div class="circle icon"><i class="fa fa-building-o fa-3x" aria-hidden="true"></i></div>
<p>Affordable Rent!*</p>
</div>
</li>
</ul>
<p class="btm-container__depends">*Depends on service purchased.</p>
</div>
</section>
and CSS
.btm-container {
background-color:rgba(255, 236, 0, 0.7);
text-align: center;
margin:0;
padding: 8px;
color: black;
font-family: 'Kalam', cursive;
font-weight: bolder;
font-size: 1.5rem;
}
.bottom__container li {
list-style: none;
display: inline-block;
padding: 32px;
}
.lists {
display: flex;
justify-content: center;
list-style: none;
margin: 0;
padding: 2rem;
text-align: center;
margin-top: 20px;
}
.btm-container__why {
font-size:2.5rem;
margin:0;
}
.btm-container__depends {
font-size: small;
text-align: right;
font-family: initial;
}
.list-item {
flex-grow: 1;
flex-basis: 0;
p {
position: absolute;
padding: 0 70px;
}
}
.circle {
width: 128px;
height: 128px;
border: 2px solid #424242;
border-radius: 50%;
margin: 0;
background-color: white;
}
.d-flex {
display: flex
}
.align-items-center {
align-items: center;
}
.flex-column {
flex-direction: column;
}
.justify-content-center {
justify-content: center;
}
.position-relative {
position: relative;
}

gap borders' right and left

When I applied padding to 'a' elements, there will be gaps top-borders' left and right.I want the top border covers entire line until navbar's right border. How can I solve this problem.
* {
margin: 0;
padding: 0;
font-family: 'Lato', sans-serif;
}
.wrapper {
display: grid;
grid-template-columns: 1fr 6fr;
}
.navbar {
border-right: gray 3px solid;
padding: 5%;
position: sticky;
top: 0;
height: 100vh;
box-sizing: border-box;
min-width: 300px;
}
#navbar-header {
text-align: center;
margin-bottom: 20px;
}
#navbar-content a {
text-decoration: none;
color: black;
}
#navbar-content a li {
list-style: none;
padding: 5%;
padding-left: 10%;
border-top: gray 1px solid;
}
<div class="wrapper">
<div class="navbar">
<h2 id="navbar-header">JS Documentation</h2>
<ul id="navbar-content">
<a href="#intro">
<li>Introduction</li>
</a>
<a href="#know">
<li>What you should already know</li>
</a>
<a href="#js-java">
<li>JavaScript and Java</li>
</a>
<a href="#hello">
<li>Hello World</li>
</a>
<a href="#var">
<li>Variables</li>
</a>
<a href="#dec-var">
<li>Declaring Variables</li>
</a>
<a href="#var-sco">
<li>Variable Scope</li>
</a>
<a href="#glo-var">
<li>Global Variables</li>
</a>
<a href="#cons">
<li>Constants</li>
</a>
<a href="#data">
<li>Data Types</li>
</a>
<a href="#if-else">
<li>if...else statement</li>
</a>
<a href="#while">
<li>while statement</li>
</a>
<a href="#func">
<li>Function declarations</li>
</a>
<a href="#ref">
<li>Reference</li>
</a>
</ul>
</div>
<div class="contents">
</div>
</div>
When I applied padding to 'a' elements, there will be gaps top-borders' left and right.I want the top border covers entire line until navbar's right border. How can I solve this problem.
Remove the padding-left/right from the navbar and increase the one of the li:
* {
margin: 0;
padding: 0;
font-family: 'Lato', sans-serif;
}
.wrapper {
display: grid;
grid-template-columns: 1fr 6fr;
}
.navbar {
border-right: gray 3px solid;
padding: 5% 0; /*updated*/
position: sticky;
top: 0;
height: 100vh;
box-sizing: border-box;
min-width: 300px;
}
#navbar-header {
text-align: center;
margin-bottom: 20px;
}
#navbar-content a {
text-decoration: none;
color: black;
}
#navbar-content a li {
list-style: none;
padding: 5% 10%; /*updated*/
border-top: gray 1px solid;
}
<div class="wrapper">
<div class="navbar">
<h2 id="navbar-header">JS Documentation</h2>
<ul id="navbar-content">
<a href="#intro">
<li>Introduction</li>
</a>
<a href="#know">
<li>What you should already know</li>
</a>
<a href="#js-java">
<li>JavaScript and Java</li>
</a>
<a href="#hello">
<li>Hello World</li>
</a>
<a href="#var">
<li>Variables</li>
</a>
<a href="#dec-var">
<li>Declaring Variables</li>
</a>
<a href="#var-sco">
<li>Variable Scope</li>
</a>
<a href="#glo-var">
<li>Global Variables</li>
</a>
<a href="#cons">
<li>Constants</li>
</a>
<a href="#data">
<li>Data Types</li>
</a>
<a href="#if-else">
<li>if...else statement</li>
</a>
<a href="#while">
<li>while statement</li>
</a>
<a href="#func">
<li>Function declarations</li>
</a>
<a href="#ref">
<li>Reference</li>
</a>
</ul>
</div>
<div class="contents">
</div>
</div>

How to remove the Large White space at the bottom of my webpage?

I have this problem of having a huge white space at the bottom of my web page. I tried for many hours to fix the problem but I can't seem to find where I have gone wrong. Can anybody please help me with the problem? I have attached my code samples below...
Here's my code sample. (HTML)
<!DOCTYPE html>
<html>
<head>
<title>Web Page Exercise 2</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="css/custom.css">
</head>
<body>
<div class="UpperHeader"></div>
<div class="SliitLogo">
<img src="images/SLIIT Logo.png" width="25%" height="75">
</div>
<div class="Login">
Login
</div>
<div class="Register">
Register
</div>
<div class="SliitLibrary">
<h1>SLIIT<span id="Space">LIBRARY</span></h1>
</div>
<div id="UpperNavigationBar">
<div class="UpperNavigationBarContents">
<ul>
<li>
<div><p style="width: 100px;color: white;">Home</p></div>
</li>
<li>
<div><p style="width: 120px;color: white;">About Us</p></div>
</li>
<li>
<div><p style="width: 145px;color: white">Membership</p></div>
</li>
<li>
<div><p style="width: 100px;color: white">Search</p></div>
</li>
<li>
<div><p style="width: 150px;color: white">New Arrivals</p></div>
</li>
<li>
<div><p style="width: 145px;color: white">Staff</p></div>
</li>
</ul>
</div>
</div>
<div class="BackgroundPicture"></div>
<h3 style="position: relative;top: -610px; left: 10px;">Categories</h3>
<div class="SideNavagationBar1">
<UL TYPE="none">
<LI>OPAC Search</LI>
<LI>New Arrivals</LI>
<LI>How to Become a Member</LI>
<LI>Central Bank of Sri Lanka</LI>
<LI>e-Repository</LI>
<LI>Dictionary</LI>
<LI>Library Policies</LI>
<LI>University of Moratuwa</LI>
</UL>
</div>
<h3 style="position: relative;top: -590px;left: 10px;">E-Resources</h3>
<div class="SideNavagationBar2">
<UL TYPE="none">
<LI><div style="text-decoration: none;color: black;">Find the Journals</div></LI>
<LI><a style="text-decoration: none;">Online Journals</a></LI>
<LI><div style="text-decoration: none;">Access the available databases</div></LI>
<LI>Databases</LI>
<LI><div style="text-decoration: none;">Getting start with Research?</div></LI>
<LI>Research Papers</LI>
<LI><div style="text-decoration: none;">What is done already?</div></LI>
<LI>Thesis Dissertion</LI>
<LI><div style="text-decoration: none;">Help!!!</div></LI>
<LI>Library Guide</LI>
<LI><div style="text-decoration: none;">Turnitin</div></LI>
<LI>Turnitin</LI>
</UL>
</div>
</body>
</html>
And here's my CSS sample for the above HTML
.UpperHeader{
background-color: #808080;
width: 100%;
height: 160px;
}
.SliitLogo{
position: relative;
top: -150px;
left: 5px;
margin-right: 10px;
}
.Login{
position: absolute;
float: right;
right: 100px;
top: 40px;
font-size: 10px;
}
.Register{
position: absolute;
float: right;
right: 30px;
top: 40px;
font-size: 10px;
}
.SliitLibrary{
position: relative;
float:right;
right: 20px;
top: -200px;
color: white;
font-family: Lifetime;
}
#Space{
display:inline-block;
margin-left: 10px;
}
#UpperNavigationBar{
background-color: #333333;
position: relative;
top: -140px;
margin: 0px auto;
width: 98%;
height: 35px;
}
.UpperNavigationBarContents li{
display:block;
float:left;
position:relative;
top: -7px;
left: -20px;
color: white;
}
.SideNavagationBar1{
position: relative;
top: -600px;
font-size: 14px;
}
.SideNavagationBar1 li>a{
color: blue;
}
.SideNavagationBar1 li:not(:last-child) {
margin-bottom: 3px;
}
.SideNavagationBar2{
position: relative;
margin-left: 0;
top: -600px;
font-size: 14px;
border: 2px solid red;
}
.SideNavagationBar2 li>a{
color: blue;
}
.SideNavagationBar2 li:not(:last-child) {
margin-bottom: 20px;
}
.BackgroundPicture{
position: relative;
bottom: 0;
top: -130px;
background-color: #d3d3d3;
width: 100%;
min-height: 80vh;
}
The problem is I see a huge white space below the the web page. A huge one. Can anybody please help me???
.UpperHeader{
background-color: #808080;
width: 100%;
height: 160px;
}
.SliitLogo{
position: relative;
top: -150px;
left: 5px;
margin-right: 10px;
}
.Login{
position: absolute;
float: right;
right: 100px;
top: 40px;
font-size: 10px;
}
.Register{
position: absolute;
float: right;
right: 30px;
top: 40px;
font-size: 10px;
}
.SliitLibrary{
position: relative;
float:right;
right: 20px;
top: -200px;
color: white;
font-family: Lifetime;
}
#Space{
display:inline-block;
margin-left: 10px;
}
#UpperNavigationBar{
background-color: #333333;
position: relative;
top: -140px;
margin: 0px auto;
width: 98%;
height: 35px;
}
.UpperNavigationBarContents li{
display:block;
float:left;
position:relative;
top: -7px;
left: -20px;
color: white;
}
.SideNavagationBar1{
position: relative;
top: -600px;
font-size: 14px;
}
.SideNavagationBar1 li>a{
color: blue;
}
.SideNavagationBar1 li:not(:last-child) {
margin-bottom: 3px;
}
.SideNavagationBar2{
position: relative;
margin-left: 0;
top: -600px;
font-size: 14px;
border: 2px solid red;
}
.SideNavagationBar2 li>a{
color: blue;
}
.SideNavagationBar2 li:not(:last-child) {
margin-bottom: 20px;
}
.BackgroundPicture{
position: relative;
bottom: 0;
top: -130px;
background-color: #d3d3d3;
width: 100%;
min-height: 80vh;
}
<!-- IT No: IT17157124 -->
<!-- ID No: 952314017V -->
<!-- Name: Jananth Banuka Jayarathna -->
<!DOCTYPE html>
<html>
<head>
<title>Web Page Exercise 2</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="css/custom.css">
</head>
<body>
<div class="UpperHeader"></div>
<div class="SliitLogo">
<img src="images/SLIIT Logo.png" width="25%" height="75">
</div>
<div class="Login">
Login
</div>
<div class="Register">
Register
</div>
<div class="SliitLibrary">
<h1>SLIIT<span id="Space">LIBRARY</span></h1>
</div>
<div id="UpperNavigationBar">
<div class="UpperNavigationBarContents">
<ul>
<li>
<div><p style="width: 100px;color: white;">Home</p></div>
</li>
<li>
<div><p style="width: 120px;color: white;">About Us</p></div>
</li>
<li>
<div><p style="width: 145px;color: white">Membership</p></div>
</li>
<li>
<div><p style="width: 100px;color: white">Search</p></div>
</li>
<li>
<div><p style="width: 150px;color: white">New Arrivals</p></div>
</li>
<li>
<div><p style="width: 145px;color: white">Staff</p></div>
</li>
</ul>
</div>
</div>
<div class="BackgroundPicture"></div>
<h3 style="position: relative;top: -610px; left: 10px;">Categories</h3>
<div class="SideNavagationBar1">
<UL TYPE="none">
<LI>OPAC Search</LI>
<LI>New Arrivals</LI>
<LI>How to Become a Member</LI>
<LI>Central Bank of Sri Lanka</LI>
<LI>e-Repository</LI>
<LI>Dictionary</LI>
<LI>Library Policies</LI>
<LI>University of Moratuwa</LI>
</UL>
</div>
<h3 style="position: relative;top: -590px;left: 10px;">E-Resources</h3>
<div class="SideNavagationBar2">
<UL TYPE="none">
<LI><div style="text-decoration: none;color: black;">Find the Journals</div></LI>
<LI><a style="text-decoration: none;">Online Journals</a></LI>
<LI><div style="text-decoration: none;">Access the available databases</div></LI>
<LI>Databases</LI>
<LI><div style="text-decoration: none;">Getting start with Research?</div></LI>
<LI>Research Papers</LI>
<LI><div style="text-decoration: none;">What is done already?</div></LI>
<LI>Thesis Dissertion</LI>
<LI><div style="text-decoration: none;">Help!!!</div></LI>
<LI>Library Guide</LI>
<LI><div style="text-decoration: none;">Turnitin</div></LI>
<LI>Turnitin</LI>
</UL>
</div>
</body>
</html>
You should
avoid relative positioning if you really don't need it. Because relatively positioned elements occupy the same space as if they would be statically positioned (by default).
place elements in needed containers.
Demo:
body {
background-color: #d3d3d3;
margin: 0;
}
.UpperHeader {
background-color: #808080;
height: 160px;
padding-top: 20px;
padding-bottom: 20px;
}
.SliitLogo {
margin-right: 10px;
}
.Login {
float: right;
font-size: 10px;
}
.Register {
float: right;
font-size: 10px;
}
.SliitLibrary {
color: white;
font-family: Lifetime;
}
#Space {
display: inline-block;
margin-left: 10px;
}
#UpperNavigationBar {
background-color: #333333;
margin: 0px auto;
width: 98%;
height: 35px;
}
.UpperNavigationBarContents li {
display: block;
float: left;
color: white;
}
.SideNavagationBar1 {
font-size: 14px;
}
.SideNavagationBar1 li>a {
color: blue;
}
.SideNavagationBar1 li:not(:last-child) {
margin-bottom: 3px;
}
.SideNavagationBar2 {
border: 2px solid red;
}
.SideNavagationBar2 li>a {
color: blue;
}
.SideNavagationBar2 li:not(:last-child) {
margin-bottom: 20px;
}
<div class="UpperHeader">
<div class="SliitLogo">
<img src="images/SLIIT Logo.png" width="25%" height="75">
</div>
<div class="Login">
Login
</div>
<div class="Register">
Register
</div>
<div class="SliitLibrary">
<h1>SLIIT<span id="Space">LIBRARY</span></h1>
</div>
</div>
<div id="UpperNavigationBar">
<div class="UpperNavigationBarContents">
<ul>
<li>
<div>
<a href="#" style="text-decoration: none">
<p style="width: 100px;color: white;">Home</p>
</a>
</div>
</li>
<li>
<div>
<a href="#" style="text-decoration: none">
<p style="width: 120px;color: white;">About Us</p>
</a>
</div>
</li>
<li>
<div>
<a href="#" style="text-decoration: none">
<p style="width: 145px;color: white">Membership</p>
</a>
</div>
</li>
<li>
<div>
<a href="#" style="text-decoration: none">
<p style="width: 100px;color: white">Search</p>
</a>
</div>
</li>
<li>
<div>
<a href="#" style="text-decoration: none">
<p style="width: 150px;color: white">New Arrivals</p>
</a>
</div>
</li>
<li>
<div>
<a href="#" style="text-decoration: none">
<p style="width: 145px;color: white">Staff</p>
</a>
</div>
</li>
</ul>
</div>
</div>
<h3>Categories</h3>
<div class="SideNavagationBar1">
<div>OPAC Search</div>
<div>New Arrivals</div>
<div>How to Become a Member</div>
<div>Central Bank of Sri Lanka</div>
<div>e-Repository</div>
<div>Dictionary</div>
<div>Library Policies</div>
<div>University of Moratuwa</div>
<h3>E-Resources</h3>
<div class="SideNavagationBar2">
<UL TYPE="none">
<LI>
<div style="text-decoration: none;color: black;">Find the Journals</div>
</LI>
<LI><a style="text-decoration: none;">Online Journals</a></LI>
<LI>
<div style="text-decoration: none;">Access the available databases</div>
</LI>
<LI>Databases</LI>
<LI>
<div style="text-decoration: none;">Getting start with Research?</div>
</LI>
<LI>Research Papers</LI>
<LI>
<div style="text-decoration: none;">What is done already?</div>
</LI>
<LI>Thesis Dissertion</LI>
<LI>
<div style="text-decoration: none;">Help!!!</div>
</LI>
<LI>Library Guide</LI>
<LI>
<div style="text-decoration: none;">Turnitin</div>
</LI>
<LI>Turnitin</LI>
</UL>
</div>
Don't know if it helps, but when you use some relative positioning, keep in mind that the original place of the DOM element keeps.
In your CSS you have many element that have relative position with negative values, so, white space is the "ghost" of the orignal places of these elements.

How to remove blank space between banner and top of page

HTML
<html>
<head>
<link rel="shortcut icon" href=".\favicon.ico">
<title>rentPRO</title>
</head>
<body>
<nav id="top_menu">
<ul>
<li class="current">Home</li>
<li>My Profile</li>
<li>The Fleet
<ul>
<li>Nissan</li>
<li>Toyota</li>
<li>Honda</li>
<li>Mazda</li>
</ul>
</li>
<li>Other Services</li>
<li>Terms and Conditions</li>
<li>Frequently Asked Questions</li>
<li>About Us</li>
</ul>
</nav>
<div id="wrapper">
<div id="header">
</div>
<div class="content">
</div>
<div id="footer">© rentPRO 2015</div>
</div>
</body>
</html>
CSS
#header {
background-image: url("https://lh4.googleusercontent.com/-bBxOrYzmzQE/VM57QXCUoEI/AAAAAAAAAGg/WSUG7fe2ekE/w1024-h190-no/port-louis-capital-city-picture-courtesy-mauritius-tourism-promotion-authority_gallery_small.jpg");
background-size: 100% 100%;
width: 1050px;
height: 190px;
margin: 0 auto;
}
#top_menu {
display:block;
position:relative;
top: 200px;
border-radius: 5px;
border-width: 1px 1px 1px;
border-style:solid;
background-color: #e5e5e5;
font: bold 16px Tahoma;
height: 40px;
width: 1075px;
margin: 0 auto;
border-color: black;
}
The height: 40px; is making the banner to come down by 40px, thus leaving a blank space between the top of the page and the banner. When I remove this line, the problem goes away but the navigation bar no more has a background. Can anybody tell me what is wrong here?
First thing you have to put your <nav>tag inside the div with id header.
Set top: 190px; in #top_menu.
HTML :
<head>
<link rel="shortcut icon" href=".\favicon.ico">
<title>rentPRO</title>
</head>
<body>
<div id="wrapper">
<div id="header">
<nav id="top_menu">
<ul>
<li class="current">Home</li>
<li>My Profile</li>
<li>The Fleet
<ul>
<li>Nissan</li>
<li>Toyota</li>
<li>Honda</li>
<li>Mazda</li>
</ul>
</li>
<li>Other Services</li>
<li>Terms and Conditions</li>
<li>Frequently Asked Questions</li>
<li>About Us</li>
</ul>
</nav>
</div>
<div class="content">
</div>
<div id="footer">© rentPRO 2015</div>
</div>
</body>
</html>
CSS:
#header {
background-image: url("https://lh4.googleusercontent.com/-bBxOrYzmzQE/VM57QXCUoEI/AAAAAAAAAGg/WSUG7fe2ekE/w1024-h190-no/port-louis-capital-city-picture-courtesy-mauritius-tourism-promotion-authority_gallery_small.jpg");
background-size: 100% 100%;
width: 1050px;
height: 190px;
margin: 0 auto;
}
#top_menu {
display:block;
position:relative;
top: 190px;
border-radius: 5px;
border-width: 1px 1px 1px;
border-style:solid;
background-color: #e5e5e5;
font: bold 16px Tahoma;
height: 40px;
width: 1075px;
margin: 0 auto;
border-color: black;
}
check fiddle
try this code, i moved your header tag above your menu, took away the height and changed the top menu height to 20.
</head>
<body>
<div id="header"></div>
<nav id="top_menu">
<ul>
<li class="current">Home</li>
<li>My Profile</li>
<li>The Fleet
<ul>
<li>Nissan</li>
<li>Toyota</li>
<li>Honda</li>
<li>Mazda</li>
</ul>
</li>
<li>Other Services</li>
<li>Terms and Conditions</li>
<li>Frequently Asked Questions</li>
<li>About Us</li>
</ul>
</nav>
<div id="wrapper">
<div class="content">
</div>
<div id="footer">© rentPRO 2015</div>
</div>
</body>
</html>
#header {
background-image: url("https://lh4.googleusercontent.com/-bBxOrYzmzQE/VM57QXCUoEI/AAAAAAAAAGg/WSUG7fe2ekE/w1024-h190-no/port-louis-capital-city-picture-courtesy-mauritius-tourism-promotion-authority_gallery_small.jpg");
background-size: 100% 100%;
width: 1050px;
height: 190px;
margin: 0 auto;
}
#top_menu {
display:block;
position:relative;
top: 20px;
border-radius: 5px;
border-width: 1px 1px 1px;
border-style:solid;
background-color: #e5e5e5;
font: bold 16px Tahoma;
width: 1075px;
margin: 0 auto;
border-color: black;
}
It would help you:
html, body {margin: 0; padding: 0}
#banner {
background-image: url("https://lh4.googleusercontent.com/-bBxOrYzmzQE/VM57QXCUoEI/AAAAAAAAAGg/WSUG7fe2ekE/w1024-h190-no/port-louis-capital-city-picture-courtesy-mauritius-tourism-promotion-authority_gallery_small.jpg");
background-size: 100% 100%;
width: 1050px;
height: 190px;
margin: 0 auto;
}
#top_menu {
display:block;
position:relative;
/*top: 200px;*/
border-radius: 5px;
border-width: 1px 1px 1px;
border-style:solid;
background-color: #e5e5e5;
font: bold 16px Tahoma;
height: 40px;
width: 1075px;
margin: 0 auto;
border-color: black;
}
And the HTML:
<header>
<div id="banner">
</div>
<nav id="top_menu">
<ul>
<li class="current">Home</li>
<li>My Profile</li>
<li>The Fleet
<ul>
<li>Nissan</li>
<li>Toyota</li>
<li>Honda</li>
<li>Mazda</li>
</ul>
</li>
<li>Other Services</li>
<li>Terms and Conditions</li>
<li>Frequently Asked Questions</li>
<li>About Us</li>
</ul>
</nav>
</header>
<div id="wrapper">
<div class="content">
</div>
</div>
<footer>
<div id="footer">© rentPRO 2015</div>
</footer>
If you are able to change the order of elements in your HTML, the simplest solution is to insert #top_menu between #header and #content. This structure more accurately reflects the structure you want to display and the elements will flow naturally. You can remove height and top from #top_menu.
<div id="wrapper">
<div id="header"></div>
<nav id="top_menu"> ... </nav>
<div class="content"></div>
<div id="footer">© rentPRO 2015</div>
</div>
Example below:
html,
body {
margin: 0;
}
#header {
background-image: url("https://lh4.googleusercontent.com/-bBxOrYzmzQE/VM57QXCUoEI/AAAAAAAAAGg/WSUG7fe2ekE/w1024-h190-no/port-louis-capital-city-picture-courtesy-mauritius-tourism-promotion-authority_gallery_small.jpg");
background-size: 100% 100%;
width: 1050px;
height: 190px;
margin: 0 auto;
}
#top_menu {
display: block;
position: relative;
border-radius: 5px;
border-width: 1px 1px 1px;
border-style: solid;
background-color: #e5e5e5;
font: bold 16px Tahoma;
width: 1075px;
margin: 0 auto;
border-color: black;
}
<div id="wrapper">
<div id="header"></div>
<nav id="top_menu">
<ul>
<li class="current">Home</li>
<li>My Profile</li>
<li>The Fleet
<ul>
<li>Nissan</li>
<li>Toyota</li>
<li>Honda</li>
<li>Mazda</li>
</ul>
</li>
<li>Other Services</li>
<li>Terms and Conditions</li>
<li>Frequently Asked Questions</li>
<li>About Us</li>
</ul>
</nav>
<div class="content"></div>
<div id="footer">© rentPRO 2015</div>
</div>

Resources