How to remove whitespace on a nav bar - html

Here's a screenshot of the issue I'm having:
I cannot for the life of me figure out how to remove the empty space on either side of the navbar. I've tried making the margin and padding 0 but it hasn't been working. Any help would be appreciated.
Here is the html:
html,
body {
margin: 0;
padding: 0;
height: 100%;
background-image: url("images/bg.jpg");
background-repeat: no-repeat;
background-position: center top;
font-family: Times New Roman;
}
header {
clear: both;
text-align: center;
}
#header img {
height: 40%;
width: 40%;
}
#wrap {
width: 1000px;
margin: auto;
padding: auto;
overflow: auto;
}
ul {
padding: 0;
}
nav ul {
margin: auto;
padding: auto;
list-style-type: none;
background-color: #009BB2;
}
nav li {
display: inline;
padding-left: 10px;
}
nav a {
text-decoration: none;
padding: 5px;
font-family: Times New Roman;
font-size: 25px;
color: maroon;
}
nav a:hover {
color: blue;
}
img.size {
height: 15%;
width: 15%;
padding: 5px;
}
section h1 {
text-align: center;
}
figure {
float: right;
overflow: hidden;
margin: 0px;
padding: 0px;
}
<div id="wrap">
<header>
<div id="header">
<img src="logo.png" alt="The Seasons" />
</div>
<nav>
<ul>
<li>Fall</li>
<li>Spring</li>
<li>Summer</li>
<li>Winter</li>
<li>Home</li>
</ul>
</nav>
</header>
<section>
<h1>The Four Seasons of the Earth</h1>
<figure class="fig">
<img class="size" src="images/fall_front.png" alt="Fall" />
</figure>
<figure class="fig">
<img class="size" src="images/winter_front.png" alt="Winter" />
</figure>
<figure class="fig">
<img class="size" src="images/spring_front.png" alt="Spring" />
</figure>
<figure class="fig">
<img class="size" src="images/summer_front.png" alt="Summer" />
</figure>
</section>
</div>

Add display: inline-block; to your nav ul selector and that will remove the whitespace from the sides.
html,
body {
margin: 0;
padding: 0;
height: 100%;
background-image: url("images/bg.jpg");
background-repeat: no-repeat;
background-position: center top;
font-family: Times New Roman;
}
header {
clear: both;
text-align: center;
}
#header img {
height: 40%;
width: 40%;
}
#wrap {
width: 1000px;
margin: auto;
padding: auto;
overflow: auto;
}
ul {
padding: 0;
}
nav ul {
margin: auto;
padding: auto;
list-style-type: none;
background-color: #009BB2;
display: inline-block;
}
nav li {
display: inline;
padding-left: 10px;
}
nav a {
text-decoration: none;
padding: 5px;
font-family: Times New Roman;
font-size: 25px;
color: maroon;
}
nav a:hover {
color: blue;
}
img.size {
height: 15%;
width: 15%;
padding: 5px;
}
section h1 {
text-align: center;
}
figure {
float: right;
overflow: hidden;
margin: 0px;
padding: 0px;
}
<div id="wrap">
<header>
<div id="header">
<img src="logo.png" alt="The Seasons" />
</div>
<nav>
<ul>
<li>Fall</li>
<li>Spring</li>
<li>Summer</li>
<li>Winter</li>
<li>Home</li>
</ul>
</nav>
</header>
<section>
<h1>The Four Seasons of the Earth</h1>
<figure class="fig">
<img class="size" src="images/fall_front.png" alt="Fall" />
</figure>
<figure class="fig">
<img class="size" src="images/winter_front.png" alt="Winter" />
</figure>
<figure class="fig">
<img class="size" src="images/spring_front.png" alt="Spring" />
</figure>
<figure class="fig">
<img class="size" src="images/summer_front.png" alt="Summer" />
</figure>
</section>
</div>

You're maxing out the width at 1000px:
#wrap{
width:1000px;
}
The nav is within that, so it can't stretch wider than that.

As is noted by others, you're setting the width to 1000px;
Change#wrap{width: 1000px} to #wrap{width: 100%}

Related

Gap in-between image grid

* {
margin: 0 auto;
}
.photos {
padding: 5%;
background-color: #27ae60;
box-sizing: content-box;
}
.photos > .photos-wrapper {
width: 100%;
text-align: center;
align-content: center;
overflow: hidden;
}
.photos > .photos-wrapper > .photo-1 {
width: 50%;
float: left;
display: inline-block;
margin: 0;
}
.photos > .photos-wrapper > .photo-1 > img {
width: 100%;
margin: 0%;
}
.photos > .photos-wrapper > a > button {
border: none;
background-color: black;
text-transform: uppercase;
font-weight: 800;
letter-spacing: 5px;
border-radius: 5px;
color: white;
margin: 2% 2%;
cursor: auto;
padding: 2% 6%;
}
<div class="photos">
<div class="photos-wrapper wrapper">
<div class="photo-1">
<img src="https://s-media-cache-ak0.pinimg.com/originals/2c/57/83/2c57831c6f450a30dc21bd4353b3107a.jpg" alt="Mountain Photography">
</div>
<div class="photo-1">
<img src="https://i.vimeocdn.com/video/376212686_1280.jpg">
</div>
<div class="photo-1">
<img src="http://www.airpixa.co.uk/images/architectural-photography-london-skyline.jpg?crc=4158542412" alt="Mountain Photography">
</div>
<div class="photo-1">
<img src="http://www.larissajoice.co.uk/wp-content/uploads/2016/11/M-Shed-Wedding-Photography-Bristol_0212.jpg" alt="Mountain Photography">
</div>
<div class="photo-1">
<img src="https://i.ytimg.com/vi/XdYEzui3Ttc/maxresdefault.jpg" alt="Mountain Photography">
</div>
<div class="photo-1">
<img src="https://nhd.usgs.gov/photos/08_Hells_Canyon.jpg" alt="Mountain Photography">
</div>
</div>
</div>
http://codepen.io/anon/pen/BWQJgO
As seen here, I'm trying to make an image grid, but there is a gap between the row of images which I'd like to get rid of. Any help would be appreciated! :)
Try adding this style: .photos img { display: block; }
See this codepen

Pictures behaving very strangely

My buddy had a problem with a website for a school project. He wanted to make a small gallery.
The first 5 pictures worked as intentional:
but then they showed up like that:
We tested all sorts of stuff for an hour. We tried to put the bottom 3 ones in another div block with class="bilder" but it was the same. We also tried putting the pictures in a different order to see if it has something to do with the pictures themselves but also the same result.
div.wrapper {
font-family: Calibri;
width: 100%;
float: left;
color: white;
}
h1 {
color: #F99F00;
text-align: center;
}
body {
background-color: black;
margin: 0;
padding: 0;
}
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: black;
}
li {
float: left;
font-family: fantasy;
font-size: 120%
}
li a {
color: white;
display: block;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
li a:hover:not(.active) {
background-color: green;
}
.active {
backround-color: green;
}
li.selected a {
color: green;
display: block;
}
#tct {
top: 15%;
left: 5%;
padding: 1%;
color: #F99F00;
font-size: 200%;
}
div.bilder img {
padding: 1%;
width: 18%;
float: left;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Counter-Strike: Global Offensive</title>
<link href="../css/waffenliste.css" rel="stylesheet" type="text/css">
<link href="pictures/csgotab.png" rel="shortcut icon" type="image/x-icon">
</head>
<body>
<div class="wrapper">
<div>
<h1>Counter-Strike: Global Offensive<h1>
</div>
<div>
<ul>
<li>Home</li>
<li class="selected">Waffenliste</li>
<li>Spray Patterns</a></li>
<li>Über</a></li>
<li>Impressum</li>
</ul>
</div>
<div id="tct">
<p>Kaufbar für: T und CT</p>
</div>
<div id="t">
<p>Kaufbar für: Terroristen</p>
</div>
<div id="ct">
<p>Kaufbar für: Antiterroreinheit</p>
</div>
<div class="bilder">
<img id="awp" src="pictures/awp.PNG">
<img id="scout" src="pictures/scout.PNG">
<img id="dual" src="pictures/dual.PNG">
<img id="p250" src="pictures/p250.PNG">
<img id="deagle" src="pictures/deagle.PNG">
<img id="nova" src="pictures/nova.PNG">
<img id="negev" src="pictures/negev.PNG">
<img id="m249" src="pictures/M249.PNG">
</div>
</div>
</body>
</html>
You can try using the following html and css structure,
section #imageGallery li {
display: inline-block;
margin: 20px;
list-style: none;
}
section #imageGallery li div {
width: 280px;
height: 290px;
color: black;
}
#imageGallery .one {
background-image: url(/Images1.jpg);
background-repeat: no-repeat;
background-size: cover;
background-color:#f9f8f5;
}
#imageGallery .two {
background-image: url(/Images2.jpg);
background-repeat: no-repeat;
background-size: cover;
background-color:#f9f8f5;
}
#imageGallery .three {
background-image: url(/Images3.jpg);
background-repeat: no-repeat;
background-size: cover;
background-color:#f9f8f5;
}
#imageGallery .four {
background-image: url(/Images4.jpg);
background-repeat: no-repeat;
background-size: cover;
background-color:#f9f8f5;
}
#imageGallery .five {
background-image: url(/Images5.jpg);
background-repeat: no-repeat;
background-size: cover;
background-color:#f9f8f5;
}
<section>
<ul id="imageGallery">
<li>
<div class="Image one">
</div>
</li>
<li>
<div class="Image two">
</div>
</li>
<li>
<div class="Image three">
</div>
</li>
<li>
<div class="Image four">
</div>
</li>
<li>
<div class="Image five">
</div>
</li>
</ul>
</section>
Hope it helps.
Just use following css :
div.bilder {
font-size: 0px;
}
div.bilder img {
padding: 1%;
width: 18%;
display: inline-block;
vertical-align: top;
}
It happens because you float all images. You shoudnt use floats to dispaly images in the line. Display inline-block is enough.
If you wish to stick with floating use clearfix after end of line.
.clearfix:after {
content: "";
display: table;
clear: both;
}

Float does not display

I face the problem that when I put float to my #middle-content. The float doesn't display. Moreover, this removes its background too. I want the middle-content to be at the right of #leftcontent. Help please!!
<body>
<div id="page">
<div id="banner">
<div id="cloud">
<img src="file:///C|/Users/admin/Desktop/DW CS3 Mr.Davis/Final/Cloud4.gif" width="573" height="121" /> </div>
<!--cloud-->
<div id="home">
<h2>HOME</h2>
</div>
<!--home-->
</div> <!--banner-->
<div id="maincontent">
<div id="leftcontent">
<div class="navigation">
Home
</div><!--navigation-->
<div class="navigation">
About Us
</div><!--navigation-->
<div class="navigation">
Products
</div><!--navigation-->
<div class="navigation">
Contact
</div><!--navigation-->
<div class="navigation">
ABOUT US
</div><!--navigation-->
</div> <!--leftcontent-->
<div id="middle-content">
<h1>Welcome To Bagger</h1>
</div> <!--middle-content-->
</div> <!--maincontent-->
</div> <!--page-->
</body>
And this is my CSS
#cloud {
float: left;
padding: 0px;
margin: 0px;
}
#page {
width: 800px;
margin-right: auto;
margin-left: auto;
}
#home {
float: left;
padding-left: 59px;
padding-right: 59px;
text-align:center;
left: auto;
top: auto;
right: auto;
bottom: auto;
padding-top: 37px;
padding-bottom: 37px;
}
#banner {
background-color: #78c8f0;
height: 130px;
}
.navigation {
font-family: Arial, Helvetica, sans-serif;
font-size: 18px;
text-decoration: none;
padding: 10px;
font-weight: bold;
text-align: center;
}
.navigation a {
text-decoration: none;
color: #000000;
background-position: center;
}
#maincontent {
background-color: #A6D2FF;
}
#leftcontent {
width: 150px;
display: table;
}
#middle-content {
width: 400px;
float: left;
}
You need to float the #leftcontent, and to fix the background, add a clear fix
#cloud {
float: left;
padding: 0px;
margin: 0px;
}
#page {
width: 800px;
margin-right: auto;
margin-left: auto;
}
#home {
float: left;
padding-left: 59px;
padding-right: 59px;
text-align: center;
left: auto;
top: auto;
right: auto;
bottom: auto;
padding-top: 37px;
padding-bottom: 37px;
}
#banner {
background-color: #78c8f0;
height: 130px;
}
.navigation {
font-family: Arial, Helvetica, sans-serif;
font-size: 18px;
text-decoration: none;
padding: 10px;
font-weight: bold;
text-align: center;
}
.navigation a {
text-decoration: none;
color: #000000;
background-position: center;
}
#maincontent {
background-color: #A6D2FF;
}
.clear:after {
content: '';
display: block;
clear: left;
height: 0;
}
#leftcontent {
width: 150px;
display: table;
float: left;
}
#middle-content {
padding-top: 1px;
width: 400px;
float: left;
}
<div id="page">
<div id="banner" class="clear">
<div id="cloud">
<img src="file:///C|/Users/admin/Desktop/DW CS3 Mr.Davis/Final/Cloud4.gif" width="573" height="121" />
</div>
<!--cloud-->
<div id="home">
<h2>HOME</h2>
</div>
<!--home-->
</div>
<!--banner-->
<div id="maincontent" class="clear">
<div id="leftcontent">
<div class="navigation">
Home
</div>
<!--navigation-->
<div class="navigation">
About Us
</div>
<!--navigation-->
<div class="navigation">
Products
</div>
<!--navigation-->
<div class="navigation">
Contact
</div>
<!--navigation-->
<div class="navigation">
ABOUT US
</div>
<!--navigation-->
</div>
<!--leftcontent-->
<div id="middle-content">
<h1>Welcome To Bagger</h1>
</div>
<!--middle-content-->
</div>
<!--maincontent-->
</div>
<!--page-->
I have also added 1px top padding to middle-content to stop the h2 margin causing a gap above maincontent
Update
Sounds like your dreamweaver does not support pseudo elements, see if this fixes your clear problem:
change css .clear:after to:
.clear {
display:block;
height:0;
overflow:hidden;
clear:both;
}
and then in the html above, find the divs with the clear class and remove the class, then at the end of those divs, add a physical div to see if it fixes your problem:
<div class="clear"></div>
try this
#leftcontent {
width: 150px;
float:left;
}
#middle-content {
width: 400px;
float: left;
}
also I have added
#maincontent:before,
#maincontent:after{
clear:both;
display:table;
content:"";
}
to fix the background color
working code is here
For your problems, i have the following solutions:
#maincontent can't show its background because its height is 0. You can fix it :
#maincontent {
background-color: #A6D2FF;
height:250px;
}
#leftcontent must have float:left so the middle-content to be at the right of #leftcontent
#leftcontent {
width: 150px;
display: table;
float: left;
}

I am Trying to make a header in css stretch full width across the browser

I am trying to make a header wider, so that it extends to both sides of the browser size. I have all of my content inside of a wrapper div that is set to 990px. My header is the part I want to be full width. I also am trying to make my header have a fixed position. But when i put the corrected position into the css for the header, the title and the navigation bar stack vertically and do not remain how I originally set them.
<body>
<div class="wrapper">
<header class="header">
<h1>Automotive Industries</h1>
<ul class="navbar">
<li id="contact" class="navlist">Contact</li>
<li class="navlist">Services</li>
<li class="navlist">About</li>
<li class="navlist">Home</li>
</ul>
</header>
<div class="main">
<p>Welcome to the #1 stop in automotive today</p>
<div class="article">
<img class="image" src="http://cdnedge.vinsolutions.com/dealerimages/Dealer%204697%20Images/content/car-tire-repair.jpg">
</div>
<div class="article">
<img class="image" src="http://www.lonniesautomachineshop.com/shopimg/Engines1.jpg">
</div>
<div class="article">
<img class="image" src="http://image.superstreetonline.com/f/features/modp-1011-castrol-syntec-top-car-challenge-nissan-gtr/29181584/eurp_1011_02_o+castrol_syntec_top_car_challenge+lift.jpg">
</div>
</div><!--end of main-->
<div class="main-two">
<p id="two-header">Schedule today for a free consultation</p>
<div class="article">
<img class="image" src="http://s3-media2.fl.yelpcdn.com/bphoto/YDLPwsEk_fMXIw9Xwu_8rw/ls.jpg">
</div>
<div class="article">
<img class="image" src="http://image.trucktrend.com/f/tech/1011tr_2004_gmc_sierra_buildup/28770854/1011tr_03+2004_GMC_sierra_buildup+factory_ring_and_pinion.jpg">
</div>
<div class="article">
<img class="image" src="http://aautomotivetx.com/wp-content/uploads/2013/04/Brakes.jpg">
</div>
</div><!--end of main-two-->
<div class="main-three">
<p id="two-header">Guranteed service for 30 days</p>
<div class="article">
<img class="image" src="http://bernalautobodyrepair.com/images/paint_booth.jpg">
</div>
<div class="article">
<img class="image" src="https://www.bkreader.com/wp-content/uploads/2015/06/welding-1.jpg">
</div>
<div class="article">
<img class="image" src="http://cdn.instructables.com/F4Q/QD4F/HHS9SLP0/F4QQD4FHHS9SLP0.LARGE.jpg">
</div>
</div><!--end of main-three-->
<footer class="footer">
<p class="copyright">Schedule now! Call today at (123)456-7890.</p>
<p class="copyright-two">Copyright © All Rights Reserved.</p>
<div class="social-icons">
<img src="http://www.voxlumiere.com/wp-content/uploads/2009/12/facebook-logo-resized-image-50x50.png"/>
<img src="http://www2.actionforchildren.org.uk/media/128162/twitter_50x50.jpg"/>
<img src="http://www.clickondetroit.com/image/view/-/21435108/highRes/1/-/ubsa5pz/-/50x50-Instagram-logo-png.png"/>
</div><!--end of social-icons-->
</footer>
</div><!--end of wrapper-->
* {
padding: 0;
margin: 0;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
body {
font-size: 62.5%;
font-family: arial, sans-serif;
color: black;
background-image: url("http://www.theonecar.com/wp-content/uploads/2014/02/car-shops-499.jpg"), url("http://i.ytimg.com/vi/1n5j3sy-Rok/maxresdefault.jpg");
background-repeat: no-repeat;
background-position: top, bottom;
}
.wrapper {
font-size: 1.6em;
margin: 0 auto;
width: 990px;
background-color: white;
/*padding: 2em;*/
}
header {
background-color: white;
height: 50px;
display: block;
width: 100%;
}
header h1 {
float: left;
padding: 5px;
color: rgb(95, 207, 128);
margin-top: 5px;
margin-left: 100px;
font-size: 1.8em;
}
.navlist a {
text-decoration: none;
color: black;
}
.navlist a:hover {
color: white;
background-color: rgb(95, 207, 128);
padding: 15px;
}
.navlist {
float: right;
display: inline-block;
text-align: center;
padding: 15px;
font-size: 1.2em;
}
.main {
min-height: 20px;
background-color: rgb(95, 207, 128);
display: block;
width: 100%;
}
.main p {
color: white;
font-size: 1.6em;
padding: 50px;
float: left;
width: 100%;
}
.article {
display: inline-block;
width: 33%;
padding: 63px;
}
.image {
min-width: 200px;
min-height: 200px;
max-width: 200px;
max-height: 200px;
}
.main-two {
background-color: #39ADD1;
display: block;
}
.main-two p {
color: white;
font-size: 1.6em;
padding: 50px;
text-align: right;
width: 100%;
}
.main-three {
min-height: 20px;
background-color: #f08c35;
display: block;
width: 100%;
}
.main-three p {
color: white;
font-size: 1.6em;
padding: 50px;
float: left;
width: 100%;
}
.article {
display: inline-block;
width: 33%;
padding: 63px;
}
.article {
display: inline-block;
width: 33%;
padding: 63px;
}
footer {
background-color: #294860;
}
.copyright {
text-align: center;
padding: 5px;
color: white;
font-size: 1.4em;
}
.copyright-two {
text-align: center;
padding: 5px;
color: white;
font-size: 1.4em;
}
.social-icons {
display: inline-block;
padding: 5px;
margin-left: 40.2%;
width: 100%;
}
.social-icons a {
margin-left: 5px;
header {
...
width: 100%;
min-width: 990px;
position: fixed;
left: 0;
}
Demo
You're seeing horizontal scrolling because the site loads in a frame. That shouldn't happen in a full browser window.
you header would need to be outside the wrapper since the wrapper is 990px wide.
make the header width 100% but it needs to either be on the root of the div structure or in another 100% width element.
Because it's inside you're <div class="wrapper"> It's not possible,
Move it above the wrapper and it should work.
<header class="header">
<h1>Automotive Industries</h1>
<ul class="navbar">
<li id="contact" class="navlist">Contact</li>
<li class="navlist">Services</li>
<li class="navlist">About</li>
<li class="navlist">Home</li>
</ul>
</header>
<div class="wrapper">

A top bar on a website not floating properly on Chrome

I am creating a website and this is what it should look like:
http://i.imgur.com/PjsnVPw.png
^^ That is in Internet Explorer
But on Chrome it looks like this: http://i.imgur.com/Ga6le1y.png
As you can see the Top bar on chrome shows completely wrong
The HTML and CSS for this is
HTML
<header>
<img id="logo" src="images/logo.png" alt="Logo">
<div id="topLinks">
<div id="SoicalLinks">
<img src="images/LinkedIn.png" alt="Linkedin logo">
<img src="images/twitterico.png" alt="Twitter Logo">
</div>
<div id="PhoneNumber">
01673 862133
</div>
</div>
<nav>
<ul>
<li><a class="first" href="#">Coaching</a></li>
<li>NLP</li>
<li>Course</li>
<li>Culture Change</li>
<li>Training & Consultancy</li>
</ul>
</nav>
<div class="clear"></div>
<div id="banner">
<div id="face">
<img src="images/webface.png" alt="A side on view of a face">
</div>
<div id="fishwaterimage">
<img src="images/fishwater.png" alt="a Fish with a splash of water">
</div>
<div id="quote">
<p>"...The experience has been first class, I feel privileged to have had this opportunity. Thank you team Dexter."</p>
</div>
<div id="readmore">
<p>Read more testimonials...</p>
</div>
</div>
</header>
and the CSS for all that is
body {
background-image: url(/images/background.png); background-repeat: repeat-x;
margin: 0 auto 0 auto;
width: 1024px;
}
img #logo{
float: right;
width: 325px;
display: inline;
}
#topLinks{
margin: 0 0 0 50px;
width: 250px;
display: inline;
float: right;
}
#PhoneNumber{
padding: 15px;
color: #a7a2a5;
background-color: #000;
float: right;
}
#SoicalLinks{
float: left;
}
nav{
text-align: center;
float: right;
margin: -50px 0 0 0;
width: 600px;
}
nav ul
{
list-style-type:none;
margin:0;
padding:0;
}
nav a
{
font-size: 20px;
color: #383336;
text-decoration: none;
border-left: 1px solid #b22b8d;
display:block;
padding: 0px 10px 0 10px;
}
nav li
{
display: inline;
float: left;
}
nav ul a.first {
border-left: none;
}
#banner{
box-shadow: 1.5px 2.598px 15px 0px rgb( 0, 0, 0 );
width: 900px;
height: 248px;
margin: 0 auto 0 auto;
}
#banner #face{
float: left;
z-index: 2;
position: absolute;
}
#banner #fishwaterimage{
float: right;
margin: 0 0 0 0;
z-index: 1;
}
#banner #quote{
font-size: 26px;
float: left;
z-index: 3;
margin: 25px 0 0 25px;
color: #a7a2a5;
width: 300px;
position:absolute;
}
#banner #readmore{
font-size: 15px;
float: left;
z-index: 3;
margin: 170px 0 0 25px;
color: #a7a2a5;
width: 300px;
position:absolute;
font-style: italic;
}
Anyone with any idea why that is not showing properly in chrome and the fix.
Did you try adding position: absolute or position: relative to the nav bar?