Malphai Malphai - 3 months ago 10
CSS Question

Big white gap in HTML & CSS

So I am trying to design my website and I got this big white gap between my navigation bar and image. Where have I done wrong here?

Also side note: Does anyone know how I can "box" my entire page to let there be empty white spaces on the sides?

HTML:

@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<title>Design</title>
</head>
<body>
<div class="container">
<div class="row">
<div class="box">
<div id="header">
<br />
<div style="margin-left: 1250px;">
<input id="sweBtn" type="button" value="SVENSKA" />
<input id="engBtn" type="button" value="ENGLISH" />
<input id="searchTxt" type="text" />
<input id="searchBtn" type="button" value="SÖK" />
</div>
<br />
</div>
<div class="col-sm-4 text-left" id="imgTitle">
<h1>Header</h1>
<p>Text</p>
</div>
<div class="col-sm-4">
<img id="imgHeader" src="~/img/Header.png" />
</div>
<div id="navBar">
<ul>
<li><a class="active" href="#home">Home</a></li>
<li><a href="#news">News</a></li>
<li><a href="#contact">Contact</a></li>
<li><a href="#about">About</a></li>
</ul>
</div>
</div>
</div>
</div>

<footer></footer>
</body>
</html>
<link href="~/Content/custom.css" rel="stylesheet" />


CSS

ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333;
}

li {
float: left;
}

li a {
display: block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}

li a:hover {
background-color: #111;
}

#header {
background-color: #503F31;
color: white;
padding: 30px;
}

#sweBtn {
font-family: 'Times New Roman';
background-color: Transparent;
color: grey;
}

#engBtn {
font-family: 'Times New Roman';
background-color: Transparent;
color: gold;
}

#searchTxt {
background-color: grey;
border-color: grey;
}

#searchBtn {
font-family: 'Times New Roman';
background-color: Transparent;
color: gold;
}

#imgTitle {
position: absolute;
}

#imgHeader {
height: 1000px;
width: 3400px;
}

#footer {
background-color: grey;
color: white;
padding-bottom: -250px;
}

Answer

Could it not be something to do with setting the size of the image to 3400px x 1000px in your css?

You could also put display: block; on your image in the css to remove any unsightly gaps.

To 'box' your page as you say, give your container a width or max-width and margin:auto;