Strange Whitespace Under Display:block Element - html

There is some strange whitespace that keeps appearing under all my display: block elements. It's for a meganavigation. I have no idea what is causing this. Basically, I have the code (plus some more that determines the column widths) below, and when it generates the meganav, the items that are rendered as "display:block" have a space below them. You can also see it when hovering over the items in the main navigation as well. I'm not quite sure what to do.
a {
font-family: "Frutiger LT Std 45 Light", sans-serif;
color: black;
text-decoration: none;
font-size: 10px;
display: block;
padding: 3px;
}
a:hover {
text-decoration: none;
color: white;
background-color: #c8a51b;
}
.nav {
background: #1b2c69;
width: 800px;
margin: 10px;
height: 30px;
}
.nav li {
list-style: none;
}
.nav > li {
padding: 0;
float: left;
position: relative;
}
.nav > li > a {
font-family: "Frutiger LT Std 45 Light", sans-serif;
float: left;
color: #fff;
font-size: 13px;
text-decoration: none;
line-height: 30px;
padding: 0 20px;
height: 43px;
text-transform: uppercase;
}
.nav > li:hover > a {
background: #FFF;
color: #1b2c69;
}
HTML:
<ul class="nav">
<li>Home
</li>
<li>Our Company
<div class="tab1">
<div class="container-1">
<div class="col1"> Business Reports
<br> Core Values
<br> Corp Priority Updates
<br> Critical Success Factors
<br> Daily Reports
<br> EBIT Chart
<br> HyVisability Scorecard
<br> Mission Statement
<br> Quality Vision
<br> Strategic Vision
<br>
</div>
</div>
</div>
</li>

See this link
I have added bgcolor to background to see the white space.
The fix is:
.nav > li > a {
font-family: "Frutiger LT Std 45 Light", sans-serif;
float: left;
color: #fff;
font-size: 13px;
text-decoration: none;
line-height: 30px;
padding: 0 20px;
height: 30px;
text-transform: uppercase;
}
In the above css I changed height: 43px; to height: 30px;
Because the height for all li tags should be same in tour case to achieve what you want. Hope you understand.

Related

HTML/CSS Navigation Bar Coloring [duplicate]

This question already has answers here:
How wide is the default `<body>` margin?
(4 answers)
Does UL have default margin or padding [duplicate]
(2 answers)
Closed 1 year ago.
I am trying to create a Portfolio, I am new to HTML and CSS. I am trying to get the top navigation bar, to be all black. But around the navigation bar, it shows the html's tag background color.
Image:
As you can see, well it's a little hard to see here, but around the navigation bar, it shows the background color, how do I turn it black? (Click on the image to see it better)
Code:
<!DOCTYPE html>
<html style="background-color: #111;">
<head>
<title>My Portfolio</title>
<style type="text/css">
h6 {
font-weight: light;
}
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: black;
position: sticky;
}
ul li img {
width: 2vw;
height: 2vw;
}
li {
float: left;
}
li a {
display: block;
color: grey;
text-align: center;
padding: .4vw .5vw;
text-decoration: none;
}
li a:hover {
background-color: #111;
}
#navigation-bar {
background-color: black;
color: grey;
font-weight: bold;
font-family: monospace;
font-size: 1.2vw;
}
#main-page {
background-color: #111;
color: white;
}
.header {
background-color: #111;
color: white;
text-align: center;
font-weight: bold;
font-family: cursive;
font-size: 2.5vw;
}
.sub-header {
background-color: #111;
color: white;
text-align: center;
font-weight: normal;
font-family: cursive;
font-size: 1.7vw;
}
.sub-header th{
padding-left: 1vw;
padding-right: 1vw;
}
.sub-header-two {
background-color: #111;
color: white;
text-align: center;
font-weight: normal;
font-family: cursive;
font-size: 1.1vw;
}
#copyright {
background-color: #111;
color: white;
text-align: left;
position: absolute;
bottom: .5vw;
font-weight: light;
font-family: sans;
font-size: .7vw;
}
</style>
</head>
<body>
<div id="navigation-bar">
<ul>
<li><img src="https://cdn.discordapp.com/avatars/471009727602491405/1205d2f887ec380308940bb54b593d60.webp?size=128" height="50px" width="50px"></li>
<li>Home</li>
<li>About Me</li>
<li>Languages</li>
<li>Previous Work</li>
<li style="float: right;">An Amazing Website </li>
</ul>
</div>
<div id="main-page">
<h1 class="header">Welcome to my Portfolio</h1>
<table align="center" >
<tr class="sub-header">
<th>What can I do here?</th>
<th>How can I get in contact?</th>
<th>Where can I support?</th>
</tr>
<tr class="sub-header-two">
<td><br><br>Here you can look around, or learn<br>about me! You can find info like<br>what languages I know, my previous<br>work, etc.</td>
<td>You can get in contact with me on<br>discord # killrebeest#4357</td>
<td>Just Support by supporting me, like<br>a supporter</td>
</tr>
</table>
</div>
<div id="copyright">
(C)Copyright 2022 All Rights Reserved
</div>
</body>
</html>
Add this styling
body, li {
margin: 0;
}
Explanation: It has a margin on body on top. Because of this, your nav bar is a little bit near to bottom. When you do this, you remove a default margin from top.
Also I added li because, It has also default margin on it.

Navigation Bar Padding 'missing' or body BGcolor 'spilling' into navbar

I was just continuing with making this website and all of a sudden some of my navbar padding goes 'missing' and I can't seem to pinpoint the mistake. I've already played the detective game and commented out some of the stuff I thought was interfering. Luckily I have an original picture before the screw-up and one after. Some of the 'paragraph text' will be 'placeheld' for personal reasons and I think it's irrelevant, unless it's needed in order to fix the problem.
-Thanks.
Before and after picture: http://imgur.com/a/ts1FS
Code:
CSS:
body {
background-color: #1a1a1a;
color: #ccad00;
line-height: 1.9;
font-size: 19px;
}
p.desc{
text-indent: 50px;
}
h1 {
font-family: courier;
color: #ccad00;
}
h2 {
font-family: courier;
color: #ccad00;
text-align: center;
}
#divtitle {
width: 50%;
margin:auto;
padding-top: 50px;
text-align: center;
}
h2
{
font-family:courier;
color: #99cc00;
}
p {
line-height: 1.9
text-size: 19px;
}
#nav {
list-style: none;
font-weight: bold;
margin-bottom: 10px;
width: 100%;
text-align: center;
background-color: #ccad00;
height:40px;
}
#nav ul {
list-style-type: none;
margin: 0px;
padding: 0;
}
#nav li {
margin: 0px;
}
#nav li a {
padding: 10px;
text-decoration: none;
font-weight: bold;
color: #f2f2f2;
background-color: #ccad00;
float: left
}
#nav li a:hover {
color: #0d0d0d;
background-color: #35af3b;
}
.button {
background-color: #ffa600;
border: none;
color: #998200;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 40px;
font-family: courier;
margin: 4px 2px;
-webkit-transition-duration: 0.4s; /* Safari */
transition-duration: 0.4s;
cursor: pointer;
}
.button:hover {
background-color: white;
color: #998200;
}
div#containerbttn {
width: 800px;
height: 100px;
margin: auto;
background-color: green;
}
ul.square{
list-style-type: square;
}
.center {
text-align: center;
}
html:
<div id="nav">
<ul>
<li>Home
</li>
<li>Center
</li>
<li>Rules
</li>
<li>References
</li>
<li>Rankings
</ul>
</div>
<div>
<div id="divtitle" >
<h1> text </h1>
</div> -->
<div id="containerbttn">
<button class="button">GET STARTED!</button>
<button class="button">FAQ</button>
<button class="button">RANKINGS</button>
</div>
<h2> Synopsis: </h2>
<div class="center">
<p class="desc"> Welcome to ***!. This is a free...
<ul class="square">
<li> some text </li>
<li> some text </li>
</ul>
<p class="desc" > text </p>
</div>
</html>
Your problem exists because you have set the height of the #nav element to 40 px. When you add the padding to your a element, you make it larger than the ul element. This can be solved easily by updating two lines of code.
First, remove from css:
#nav{ height:40px; }
Then, add to html after ul but before closing the nav div:
<div style="clear:both;"></div>
Here is a jsfiddle of your working page: https://jsfiddle.net/8o279n5r/
And here is a great answer on what the clear property does: What does the CSS rule clear: both do?

Fixing bottom navigation bar + fixing link to another webpage

I'd like to ask your help with my bottom navigation bar and a link on both my navigation bars.
I can't seem to make it appear in the center. Will using padding be able to fix it? I've been trying to use it, but I have to estimate the number of pixels.
My second problem is that my bottom navigation bar doesn't have the correct spacing. I already changed the font size, but it doesn't fix the problem. Right now, it appears like this: "HomeWho We AreWhat We Do...".
My third problem is that one of my links don't appear to be working. It's a link to another webpage I coded. I think I've typed it correctly, but it won't work.
Here's a fiddle:
https://jsfiddle.net/captainpokey/66szogpm/
And here's the code:
html {
100%
}
body {
background: #cecdcc;
margin: 0;
padding: 0;
color: #8c8b8a;
font-size: 18px;
font-family: "Lato", sans-serif;
}
#wrap {
background-color: #fff;
width: 1000px;
margin: 0 auto;
}
#nav {
width: 1000px;
height: 45px;
background: #dcdbda;
font-family: "Lato";
font-size: 18px;
}
#nav ul {
padding: 0;
margin: 0;
background: #dcdbda;
float: left;
margin-left: 50px;
}
#nav li {
height: 40px;
padding-top: 4px;
float: left;
position: relative;
width: 150px;
list-style: none;
}
#nav a {
display: block;
text-decoration: none;
text-align: center;
color: #949392;
}
#nav ul ul {
position: absolute;
left: 0;
top: 100%;
visibility: hidden;
margin: 0;
padding: 0;
}
#nav li:hover, #nav li:hover li {
background: #fff;
}
#nav li li:hover, #nav li li:hover li {
background: #bbb;
}
#nav li:hover ul {
visibility: visible;
}
#header {
width: 1000px;
height: 485px;
background-image: url(../images/headerphoto.jpg);
}
#content {
background-color: #fff;
font-family: "Lato", sans-serif;
color: #777674;
padding-top: 10px;
padding-bottom: 20px;
}
#content h4 {
padding-left: 150px;
padding-right: 150px;
font-family: "Lato", sans-serif;
font-size: 20px;
text-transform: bold;
}
#content p {
padding-left: 150px;
padding-right: 150px;
font-family: "Lato", sans-serif;
font-size: 18px;
text-transform: bold;
}
#footer {
background-image: url(../images/footerphoto.jpg);
width: 1000px;
height: 255px;
}
#navbottom {
padding-left: 130px;
width: 1000px;
color: #fff;
font-size: 12px;
font-family: "Lato";
}
#navbottom ul {
padding: 0;
margin: 0;
float: left;
margin-left: 20px;
margin-right: 20px;
}
#navbottom ul li {
float: left;
position: relative;
list-style-type: none;
}
#navbottom li:hover ul {
visibility: visible;
}
#navbottom a {
display: block;
text-decoration: none;
text-align: center;
color: #fff;
}
#copyright {
padding-left: 150px;
padding-right: 150px;
font-family: "Lato", sans-serif;
font-size: 16px;
}
<head>
<link rel="stylesheet" type="text/css" href="css/style.css">
<link href='http://fonts.googleapis.com/css?family=Lato:400,700,400italic,700italic' rel='stylesheet' type='text/css'>
<title>Powers & Grant, Inc.</title>
<meta charset="utf-8">
</head>
<body>
<div id="wrap">
<div id="nav">
<ul>
<li>Home</li>
<li>Who We Are</li>
<li>What We Do</li>
<li>Our Services</li>
<li>The Powers Team</li>
<li>Contact</li>
</ul>
</div>
<div id="header"></div>
<div id="content">
<p>As the Country's pioneer in sales force outsourcing, Powers knows the intricacies of managing the critical tasks involved in increasing revenues as well as saving the company from the costly maintenance of agents with minimal increase in sales growth.<br><br>
Powers and Grant Inc. currently handles and manages sales teams for various industries principally involved in the Real Estate, Consumer, and
Pharmaceutical and Direct Selling companies.<br><br>
We assist companies in enhancing their competitiveness through application of competencies and integrate these essential factors needed to survive
today's need for continued innovation.<br><br></p>
</div>
<div id="footer">
<div id="navbottom">
<ul>
<li>Home</li>
<li>Who We Are</li>
<li>What We Do</li>
<li>Our Services</li>
<li>The Powers Team</li>
<li>Contact</li>
</ul>
</div><br>
<div id="copyright">Copyright © Powers and Grant, Inc. All Rights Reserved</div>
</div>
</div>
</body>
Please help! Thank you very much in advance.
I have made the changes here.
https://jsfiddle.net/66szogpm/1/
code to align your top nav text to center
#nav li {
line-height: 40px;
float: left;
position: relative;
width: 150px;
list-style: none;
}
code to align your bottom nav
#navbottom {
padding-left: 100px;
width: 1000px;
color: #fff;
font-size: 14px;
font-family: "Lato";
margin: 0 auto;
}
#navbottom ul {
padding: 0;
margin: 0;
margin-left: 20px;
margin-right: 20px;
}
#navbottom ul li {
display: inline-block;
position: relative;
list-style-type: none;
margin: 5px 10px;
}
You have used float: left in many places, which isn't necessary. All you had to do was change the display property to inline-block.
I haven't changed it for the top nav. But, you can try it out.

Border doesn't adapt to list-style: none;

I'm currently working on designing my site, and at the moment I'm trying to sketch down the pricing elements of my SaaS. I want to have a border around my divs, but my problem is that the border goes where the list style "is", even though I have written it to be none. Or at least I think that is the error. I have no clue how to fix this! What am I doing wrong here?
Here is my HTML code:
<div id='pricing_plan2' class="grid_4">
<ul class="plan">
<li class="plan_price2">
<span id="recommend">WE RECOMMEND</span><BR />
<span class="dollar">$</span>
<span class="price">14.99</span>
<span class="month">/month</span>
</li>
<li class="plan_title2">
STANDARD ACCOUNT
</li>
<li class="features">1GB storage</li>
<li class="features">5GB bandwith</li>
<li class="features">2 domains</li>
<li class="features">3 databases</li>
<li class="features">1 FTP account</li>
<li class="features">25 Email Accounts</li>
<li class="buynow">Choose standard plan</li>
</ul>
here is the CSS:
body {
background-color: #fff;
}
#recommend {
color: #becdd6;
}
.plan_title {
background: #ecf2f6;
padding:20px;
color: #000;
text-align: center;
border-bottom: 1px solid #d9dee1;
letter-spacing: 2px;
font-weight: bold;
}
.plan_price {
color: #479ccf;
background: #ecf2f6;
text-align: center;
padding: 10px 0 0 0;
}
.dollar {
font-size: 25px;
}
.price {
font-size: 45px;
font-weight: bold;
}
.month {
font-size: 15px;
}
.features {
background:blue;
}
.features:nth-child(odd){
background: none repeat scroll 0 0 #F7F7F7;
font-size: 13px;
font-weight: bold;
padding: 10px 5px;
}
.features:nth-child(even){
background: none repeat scroll 0 0 #fff;
font-size: 13px;
font-weight: bold;
padding: 10px 5px;
}
.buynow {
background: #ecf2f6;
text-align: center;
padding: 15px;
}
.buynow a {
padding: 10px;
color: #FFF;
background-image:url('../img/btn-bg.png');
border: 1px solid #5c9439;
text-decoration: none;
}
#pricing_plan1 ul, #pricing_plan2 ul, #pricing_plan3 ul {
list-style: none;
font-family: "Helvetica Neue";
border: 1px solid #d9dee1;
}
Also if somebody sees things here that could be improved, I would love to hear it. If there are something I can shorten down, or write better for example.
Add padding-left: 0 to your ul style declaration.
#pricing_plan1 ul, #pricing_plan2 ul, #pricing_plan3 ul {
list-style: none;
font-family: "Helvetica Neue";
border: 1px solid #d9dee1;
padding-left: 0px;
}
<ul> has default left padding, and that's the reason of your code output.
Check jsFiddle demo. Both lists have list-style set to none, but only the second one has additional left-padding: 0. As you can see, the first one has exactly the same problem you're trying to solve.
ul
{
padding:0px;
margin:0px;
}

CSS horizontal nav bar displaying diagonally in IE 5.5 - 7

The nav bar displays the correct way (horisontally) in IE 8 and above and every other browser. However only IE 5.5, 6 and 7 it displays diagonally. Can any body help?
.top-nav ul {
margin: 0;
list-style: none;
line-height: normal;
}
.top-nav li {
margin-left: 220px;
}
.top-nav a {
display: block;
float: left;
height: 38px;
margin-right: 1px;
padding: 4px 30px 0 30px;
text-decoration: none;
font-size: 34px;
font-weight: bold;
font-family: 'Exo', sans-serif;
color: #FFF;
}
.top-nav a:hover {
background: #272727;
color: #18942f;
}
.top-nav .current_page_item a {
background: #252525;
color: #FFF;
}
HTML
<div class="top-nav">
<ul>
<li>Home</li>
<li>About Me</li>
<li>Skills</li>
<li class="current_page_item"> Contact</li>
</ul>
</div>
Instead of floating each link, why not use display:inline on your li, display: inline works on IE 5.5
Also you need to remove "display: Block" as this is what is causing the links to move down.
.top-nav ul {
margin: 0;
list-style: none;
line-height: normal;
}
.top-nav li {
display: inline;
}
.top-nav a {
height: 38px;
margin-right: 1px;
padding: 4px 30px 0 30px;
text-decoration: none;
font-size: 34px;
font-weight: bold;
font-family: 'Exo', sans-serif;
color: #aaa;
}​
http://jsfiddle.net/YJjya/
If you need to have your items be blocks, then use inline-block. Workaround to make it work on older version or IE can be found here: Work Around Inline Block
Also here is a handy piece of code to place immediately after your first head tag. It will only display is the user is using IE 7 or later and will tell them get their sh*t together and download a new browser. It is really not worth the time trying to make your site work on every IE version as you'll end up pulling your hair out to please a few people who obviously aren't internet savvy to begin with. As Mario said only 6% of the world still use IE6... But if you take a closer look at countries such as the US or UK that number is below 1%
After Head
<!--[if lt IE 7]>
<p class="chromeframe">You are using an outdated browser. Upgrade your browser today or install Google Chrome Frame to better experience this site.</p>
<![endif]-->
CSS
.chromeframe {
margin: 0.2em 0;
background: #ccc;
color: #000;
padding: 0.2em 0;
}
I've seen this problem many times. You want to float the LI and not the A that's inside the LI.
All you need to do is remove [float:left] from [.top-nav a] class and add it to the [.top-nav li] class. Your CSS would be:
.top-nav ul {
margin: 0;
list-style: none;
line-height: normal;
}
.top-nav li {
margin-left: 220px;
float: left;
}
.top-nav a {
display: block;
height: 38px;
margin-right: 1px;
padding: 4px 30px 0 30px;
text-decoration: none;
font-size: 34px;
font-weight: bold;
font-family: 'Exo', sans-serif;
color: #FFF;
}
.top-nav a:hover {
background: #272727;
color: #18942f;
}
.top-nav .current_page_item a {
background: #252525;
color: #FFF;
}