How do I add space between li's in following situation? - css

Given below is my scss
#import "susy";
$susy: (
columns: 12,
gutters: 0,
math: fluid,
output: float,
gutter-position: inside
);
ul {
list-style: none;
width: 240px;
}
li {
display: table-cell;
position: relative;
vertical-align: middle;
width: 60px;
height: 60px;
border-radius: 50%;
color: #019ed5;
border: 1px solid #019ed5;
background-color: white;
cursor: pointer;
text-align: center;
#include span(3);
&:nth-child(4n){
#include span(3 at 10);
}
}
li:hover {
background: #019ed5;
color: #fff;
}
span.detail{
position: relative;
top: 12px;
left: 8px;
}
span.more {
position: relative;
float: right;
width: 20px;
height: 20px;
border-radius: 50%;
background: red;
font-size: 10px;
line-height: 20px;
color: white;
}
And here is my HTML
<ul>
<li>
<span class="more">25</span>
<span class = "detail">Jan<br/>15</span>
</li>
<li>
<span class="more-statement">15</span>
<span class="detail">Feb<br/>15</span>
</li>
<li>
<span class="more">13</span>
<span class="detail">Mar<br/>15</span>
</li>
<li>
<span class="more-statement">8</span>
<span class="detail">Apr<br/>15</span>
</li>
<li>
<span class="more">30</span>
<span class="detail">May<br/>15 </span>
</li>
<li>
<span class="more">6</span>
<span class="detail">Jun<br/>15</span>
</li>
<li>
<span class="more">9</span>
<span class="detail">Jul<br/>15</span>
</li>
<li>
<span class="more">16</span>
<span class="detail">Aug<br/>1</span>
</li>
<li>
<span class="more">0</span>
<span class="detail">Sep<br/>15</span>
</li>
<li>
<span class="more">15</span>
<span class="detail">Oct<br/>15</span>
</li>
<li>
<span class="more">30</span>
<span class="detail">Nov<br/>15</span>
</li>
<li>
<span class="more">21</span>
<span class="detail">Dec<br/>15</span>
</li>
</ul>
http://codepen.io/suhasdeshpande/pen/bVwZmz?editors=110
Above is my codepen and I am really new to Sussy. Having an hard time figuring about how to add spaces between lis in above code.

Related

How do I make this responsive?

OKAY. So, I am creating a Chat site/application and I know next to nothing about CSS.
But I am alone in developing this thing, so I gotta try.
I designed the site in Photoshop, then I moved on to actually creating it w/ HTML & CSS and it looks great, but not all parts are responsive.
More specifically the messages container thing, can someone help me with either learning how to do responsiveness or just spoonfeed the entire site but with responsiveness for me? 😂
Here's my code so far:
HTML (combined with EJS):
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Home - <%= name %></title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="/global.css">
<link rel="stylesheet" href="/index.css">
</head>
<body>
<div class="content">
<div class="nav">
<h1 class="navTitle">Atlas Chat</h1>
<h2 class="navUsername"><%= user ? user.username : "Not logged in" %></h2>
<% if(user !== null) { %>
<a class="navitem logoutbtn" href="/logout">Logout</a>
<% } else { %>
<a class="navitem loginbtn" href="/login">Login</a>
<a class="navitem" href="/register">Register</a>
<% } %>
</div>
<div class="main">
<div class="roomInfo">
<span class="hashtag">#</span><input type="text" class="roomname" pattern="^[a-z0-9\-]{0,16}$" required placeholder="channel-name"><button class="roomnamebtn">Join</button>
</div>
<hr>
<div class="room">
<ul class="messages">
<li class="message"><span class="user">Atlas</span>: <span class="msgContent">This is a message.</span></li>
<li class="message"><span class="user">Atlas</span>: <span class="msgContent">This is another message.</span></li>
<li class="message"><span class="user">Atlas</span>: <span class="msgContent">This is another message.</span></li>
<li class="message"><span class="user">Atlas</span>: <span class="msgContent">This is another message.</span></li>
<li class="message"><span class="user">Atlas</span>: <span class="msgContent">This is another message.</span></li>
<li class="message"><span class="user">Atlas</span>: <span class="msgContent">This is another message.</span></li>
<li class="message"><span class="user">Atlas</span>: <span class="msgContent">This is another message.</span></li>
<li class="message"><span class="user">Atlas</span>: <span class="msgContent">This is another message.</span></li>
<li class="message"><span class="user">Atlas</span>: <span class="msgContent">This is another message.</span></li>
<li class="message"><span class="user">Atlas</span>: <span class="msgContent">This is another message.</span></li>
<li class="message"><span class="user">Atlas</span>: <span class="msgContent">This is another message.</span></li>
<li class="message"><span class="user">Atlas</span>: <span class="msgContent">This is another message.</span></li>
<li class="message"><span class="user">Atlas</span>: <span class="msgContent">This is another message.</span></li>
<li class="message"><span class="user">Atlas</span>: <span class="msgContent">This is another message.</span></li>
<li class="message"><span class="user">Atlas</span>: <span class="msgContent">This is another message.</span></li>
<li class="message"><span class="user">Atlas</span>: <span class="msgContent">This is another message.</span></li>
<li class="message"><span class="user">Atlas</span>: <span class="msgContent">This is another message.</span></li>
<li class="message"><span class="user">Atlas</span>: <span class="msgContent">This is another message.</span></li>
<li class="message"><span class="user">Atlas</span>: <span class="msgContent">This is another message.</span></li>
<li class="message"><span class="user">Atlas</span>: <span class="msgContent">This is another message.</span></li>
<li class="message"><span class="user">Atlas</span>: <span class="msgContent">This is another message.</span></li>
<li class="message"><span class="user">Atlas</span>: <span class="msgContent">This is another message.</span></li>
<li class="message"><span class="user">Atlas</span>: <span class="msgContent">This is another message.</span></li>
<li class="message"><span class="user">Atlas</span>: <span class="msgContent">This is another message.</span></li>
<li class="message"><span class="user">Atlas</span>: <span class="msgContent">This is another message.</span></li>
<li class="message"><span class="user">Atlas</span>: <span class="msgContent">This is another message.</span></li>
<li class="message"><span class="user">Atlas</span>: <span class="msgContent">This is another message.</span></li>
<li class="message"><span class="user">Atlas</span>: <span class="msgContent">This is another message.</span></li>
<li class="message"><span class="user">Atlas</span>: <span class="msgContent">This is another message.</span></li>
<li class="message"><span class="user">Atlas</span>: <span class="msgContent">This is another message.</span></li>
<li class="message"><span class="user">Atlas</span>: <span class="msgContent">This is another message.</span></li>
</ul>
<div class="inputarea">
<hr class="inputhr">
<input type="text" class="roominput" placeholder="<%= user ? "Send a message." : "Log in to join the conversation!" %>" <%= user ? "" : "disabled" %> required><button class="roomsendbtn" <%= user ? "" : "disabled" %>>Send</button>
</div>
</div>
</div>
<div class="users">
<h1 class="usersTitle">Online Users</h1>
<ul class="usersList">
<li class="usersUser">Atlas</li>
<li class="usersUser">SomeOtherGuy</li>
<li class="usersUser">SomeThirdGuy</li>
</ul>
</div>
</div>
</body>
</html>
CSS:
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
:root {
--bg1: #131318;
--bg2: #1E1E26;
--link1: #2991E9;
--link2: #1B83DA;
--btn1: #9638E5;
--btn2: #8933D1;
--text1: #ffffff;
--text2: #626262;
--border: #252525;
--success: #28D328;
--danger: #EA2828;
}
:focus {
outline: initial;
}
html {
font-family: "Open Sans";
font-size: 14px;
background-color: var(--bg1);
color: white;
}
body {
height: 100vh;
width: 100vw;
}
h1 {
font-family: "Poppins";
font-weight: 500;
}
ul {
list-style-type: none;
}
a {
text-decoration: none;
color: #35A7FF;
}
a:hover {
color: #2887D7;
text-decoration: underline;
}
.content {
display: flex;
height: 100%;
width: 100%;
}
.nav {
display: flex;
flex-direction: column;
height: 100%;
width: 15%;
overflow: auto;
list-style: none;
background-color: var(--btn1);
text-align: center;
}
.navitem {
background-color: var(--btn1);
padding: 10px 15px;
text-decoration: none;
cursor: pointer;
text-align: center;
color: white !important;
text-decoration: none;
}
.navitem:hover {
background-color: var(--btn2);
color: white !important;
text-decoration: none !important;
}
.main {
display: flex;
height: 100%;
width: 70%;
flex-direction: column;
}
.users {
display: flex;
flex-direction: column;
background-color: var(--btn1);
height: 100%;
width: 15%;
text-align: center;
}
.logoutbtn, .loginbtn {
margin-top: auto;
}
.navTitle, .usersTitle {
margin-top: 8px;
}
.roomInfo {
margin-top: 14px;
margin-bottom: 14px;
}
.hashtag {
font-size: 3rem;
vertical-align: middle;
line-height: 0;
font-family: "Poppins";
font-weight: 500;
margin-left: 16px;
color: var(--text2);
}
input.roomname {
width: 14%;
padding: 10px 8px;
font-size: 16px;
color: var(--text2);
margin-left: 12px;
margin-right: 12px;
background-color: var(--bg2);
display: inline-block;
border: 1px solid var(--border);
border-radius: 4px;
}
input.roomname:focus {
border: 1px solid var(--btn2);
}
input.roominput {
width: 85%;
padding: 10px 8px;
font-size: 16px;
color: var(--text1);
margin-left: 15px;
margin-right: 25px;
background-color: var(--bg2);
display: inline-block;
border: 1px solid var(--border);
border-radius: 4px;
}
input.roominput:focus {
border: 1px solid var(--btn2);
}
input.roominput:disabled {
cursor: not-allowed;
}
hr {
border: 0;
margin-inline-start: 15px;
margin-inline-end: 15px;
border-bottom: 2px solid var(--bg2);
}
ul.messages {
max-height: 800px;
width: 100%;
overflow-y: scroll;
padding-left: 25px;
padding-right: 25px;
padding-top: 10px;
padding-bottom: 10px;
}
li.message {
max-height: 20px;
}
li.message:not(:last-child) {
margin-bottom: 8px;
}
button.roomnamebtn {
width: 7%;
font-size: 1.3rem;
background-color: var(--btn1);
color: white;
padding: 10px 8px;
border: none;
border-radius: 4px;
cursor: pointer;
}
button.roomsendbtn {
width: 10%;
font-size: 1.3rem;
background-color: var(--btn1);
color: white;
margin-top: 14px;
padding: 10px 8px;
border: none;
border-radius: 4px;
cursor: pointer;
}
button.roomsendbtn:disabled {
cursor: not-allowed;
}
button:hover {
background-color: var(--btn2);
}
Responsive design means it changes to the size and shape of the screen.
For example, mobile designs and layouts would look silly on desktop, while desktop designs would be too cluttered to fit on mobile.
A while back I was making a mockup of a chatapp, if you don't mind I would like to use that as an example since I have the code already online to look at.
https://replit.com/#DillonBurnett/VapidDeficientTitles#index.html
When you are on mobile, the app would look something like this:
Here it is nice and easy to view, you have the chat and you can tap the buttons at the top right to view rooms, users, and settings... but this looks a little simple when viewing it on a desktop, so instead I use a bit of css to change it specifically when the screen is large to look like this:
Each "screen" is in a long div. Think of it like 4 screens width at 100% each, but they are simply hidden because they go offscreen. When you select a different "screen" it simply scrolls there instantly making it look like a new page.
#screens{
width: 100%; height: 100%;
background: #2a2a2a;
overflow: hidden;
}
#screens #viewport{
width: calc(100% * 4); height: 100%;
overflow: none;
}
#screens #viewport > *{
width: calc(100% / 4); height: 100%;
float: left;
}
However, when the user is on desktop and I want to show the "rooms" and the "chat" at the same time, I simply adjust those to fit within 1 screen.
#media only screen and (min-width: 800px){
#screens #viewport #rooms{width: 200px!important}
#screens #viewport #chat{width: calc(100% / 4 - 200px)!important;}
}
As you can see the #media tag is unique and only allows the css within it to run when the screen is at least 800 wide. Otherwise, it is simply ignored. This opens up a lot of potential for css. You can adjust your layout for portrait or landscape, widths, heights to target many different devices... even Tvs.
I used that example because the css is generally simple and easy to understand... While it is a bit long (css declarations), I hope it helps you in designing a responsive chat app. If you have any specific questions about the example let me know below.

CSS: center all list elements except last one

I'm trying to create a navbar which contains a title, some buttons and a username. I'm trying to align the buttons to the center and the username to the right, while the title stays to the left. Whatever I try, I can't get it to work. It either centers the buttons and the username, or it aligns it all to the left.
I have the feeling some conflicting styling is causing the problem, however I'm not sure and was wondering if someone could help me out.
.sidenav-container {
height: 100%;
}
.sidenav {
width: 200px;
}
.sidenav .mat-toolbar {
background: inherit;
}
.mat-toolbar.mat-primary {
position: sticky;
top: 0;
z-index: 1;
}
a {
text-decoration: none;
color: white;
}
a:hover,
a:active {
color: lightgray;
}
.icon {
display: inline-block;
height: 30px;
margin: 0 auto;
padding-right: 15px;
text-align: center;
vertical-align: middle;
width: 15%;
}
.label {
display: inline-block;
line-height: 30px;
margin: 0;
width: 85%;
}
#footer {
position:fixed;
left:0px;
bottom:0px;
height:40px;
width:100%;
background: white;
}
#menu
{
width: 100%;
margin: 0;
padding: 20px 0 0 0;
list-style: none;
display: inline-block;
}
#menu > li:last-child{
float: right;
}
<mat-sidenav-container>
<mat-sidenav #sidenav role="navigation">
<mat-nav-list>
<a mat-list-item [routerLink]="['post/list']">
<mat-icon class="icon">forum</mat-icon>
<span class="label">Posts</span>
</a>
<a mat-list-item [routerLink]="['news']">
<mat-icon class="icon">chrome_reader_mode</mat-icon>
<span class="label">News</span>
</a>
<a mat-list-item [routerLink]="['about']">
<mat-icon class="icon">dashboard</mat-icon>
<span class="label">About</span>
</a>
<a mat-list-item>
<mat-icon class="icon">output</mat-icon>
<button (click)="logout()">Logout</button>
</a>
</mat-nav-list>
</mat-sidenav>
<mat-sidenav-content>
<mat-toolbar color="primary">
<div fxHide.gt-xs>
<button mat-icon-button (click)="sidenav.toggle()">
<mat-icon>menu</mat-icon>
</button>
</div>
<div>
<a [routerLink]="['']">
BRICKER
</a>
</div>
<div fxFlex fxHide.xs>
<ul fxLayout fxLayoutGap="20px" id="menu">
<a mat-list-item [routerLink]="['post/list']">
<mat-icon class="icon">forum</mat-icon>
<span class="label">Posts</span>
</a>
<li>
<a mat-list-item [routerLink]="['news']">
<mat-icon class="icon">chrome_reader_mode</mat-icon>
<span class="label">News</span>
</a>
</li>
<li>
<a [routerLink]="['about']">
<mat-icon class="icon">dashboard</mat-icon>
<span class="label">About</span>
</a>
</li>
<li>
<span *ngIf="(loggedInUser$ | async) as user" class="label"> <button mat-button [matMenuTriggerFor]="menu"
style="font-size:24px;">{{user}}</button>
<mat-menu #menu="matMenu">
<button mat-menu-item [routerLink]="['post/owned']">My Posts</button>
<button mat-menu-item (click)="logout()">Logout</button>
</mat-menu>
</span>
</li>
</ul>
</div>
</mat-toolbar>
<ng-content></ng-content>
</mat-sidenav-content>
</mat-sidenav-container>
Are u expecting like this:
li:last-child {
color: lime;
background-color: black;
text-align:left; /*change this if you want to align right */
padding: 5px;
}
li{
text-align:center;
list-style:none;
}
<ol>
<li>one</li>
<li>two</li>
<li>Three</li>
</ol>
<ol>
<li>four</li>
<li>five</li>
<li>six</li>
</ol>

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>

Flexbox css unordered list custom styling

I want to style my unordered list like this one below
Link to what i want to achive
My structure looks like:
<div class="tabs">
<ul class="tabs__labels">
<li class="0">
<a class="active" href="#">
<img/>
<div>something</div>
</a>
</li>
<li class="1">
<a class="" href="#">
<img/>
<div>something1</div>
</a>
</li>
...
</ul>
</div>
Is it a good idea to name the list classes like 0,1 etc. and style them separately to somehow achive this effect? How to use flexbox to get similar effect? Should i group them into rows?
Would this be a start?
.tabs__labels {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
list-style: none;
margin: 0;
padding: 0;
}
.tabs__labels li {
flex-basis: 45%;
margin: 20px 0;
padding: 0;
}
.tabs__labels li:nth-child(odd) {
display: flex;
justify-content: flex-end;
}
.tabs__labels li:nth-child(even) {
display: flex;
}
.tabs__labels li:nth-child(3),
.tabs__labels li:nth-child(4) {
flex-basis: 35%;
}
.tabs__labels li a {
display: flex;
justify-content: center;
align-items: center;
height: 40px;
width: 40px;
border-radius: 50%;
border: 1px solid red;
text-decoration: none;
}
.tabs__labels li:nth-child(1)::before {
content: 'some text';
text-decoration: underline;
margin-right: 10px;
}
.tabs__labels li:nth-child(2)::after {
content: 'some text';
text-decoration: underline;
margin-left: 10px;
}
<div class="tabs">
<ul class="tabs__labels">
<li>
<a class="active" href="#">S
</a>
</li>
<li>
<a class="" href="#">S
</a>
</li>
<li>
<a class="" href="#">S
</a>
</li>
<li>
<a class="" href="#">S
</a>
</li>
<li>
<a class="" href="#">S
</a>
</li>
<li>
<a class="" href="#">S
</a>
</li>
</ul>
</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.

Resources