I would like my header to span the full width of the page, and it is not. (.red and .green), I would like my footer to not be seen until scrolled down to and then to stay at the bottom of the page, I would like my nave to be flush with the left side of the screen and stay there.
type here<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
<title>Reno, NV</title>
<style>
body {
background-image: url("RenoAtNight.jpg");
background-repeat:no-repeat;
background-attachment: fixed;
background-size: cover;
}
</style>
</head>
<body>
<header class="red">
<h1>Reno, NV</h1>
<h2>The Littlest Big City! </h2>
</header>
<nav>
<a href="index.html">Home</a>nbsp
<a href="Carson-city.html">Carson City</a>nbsp
<a href="Reno.html">Reno, NV</a>nbsp
<a href="Elko.html">Elko</a>nbsp
<a href="Las Vegas.html">Las Vegas</a>nbsp
</nav>
<section>
<p>Why Aren't you appearing, bro?
A bunch of Lorem edited out to not muddy the code too much.
</p>
</section>
<footer>
<p>
More lorem placeholder text.
</p>
</footer>>
</html>
</body>
</html>
*{
box-sizing: border-box;
}
.green{
display:block;
text-align:center;
background:radial-gradient( rgba(255, 145, 0, 0.595), rgb(138, 154, 91));
margin-top:20px;
border-top:20px black solid;
border-bottom:20px black solid;
}
.red{
text-align:center;
background:radial-gradient( rgb(4, 63, 135, 0.9), rgb(111, 4, 4, 0.95));
margin-top:20px;
border-top:20px black solid;
border-bottom:20px black solid;
left:0px;
width:100%
}
h1{
font-size:4rem;
}
nav a:hover {
color:gray;
font-size:.98em;
}
nav{
display:block;
height:100vh;
width:20%;
background-color:black;
padding:15px;
position:fixed;
margin:0px;
left:0px;
}
a {
display:block;
color:white;
}
section{
display:block;
width:70%;
background-color: rgba(255, 255, 255, 0.7);
position:relative;
left:25%;
}
footer{
position:absolute;
left: 20%;
bottom: 0;
width: 80%;
background-color: red;
color: white;
text-align: center;
}
I have played around with gridbox, float, EVERY SINGLE POSITIONING OPTION IN THE FREAKING WORLD!!!!!!
4
Answers
It’s easiest to start with some pre-built styles such as bootstrap. ref: https://getbootstrap.com/ They already have templates that will give you a sticky footer and a more modern horizontal navigation that behaves appropriately in mobile sizes e.g. https://getbootstrap.com/docs/5.3/examples/sticky-footer-navbar/
"I would like my header to span the full width of the page, and it is not."
"I would like my footer to not be seen until scrolled down to and then to stay at the bottom of the page"
"I would like my nave to be flush with the left side of the screen and stay there."
"I have played around with gridbox, float,…."
Try this code:
This is very low quality effort. Please go through some online tutorial how to layout web page. I would recommend https://www.w3schools.com/css/css3_flexbox.asp.
You layout is messed up. There is not header, no main container, no footer. Only tag with random css.
You do not use position randomly.
Most browsers have their default style on the
body
tag,margin: 8px
; that’s where the white space came from. You can use the below CSS to overwrite it.Don’t use
position: absolute;
, just leave it as defaultposition
.You should check out the flexbox layout.
Wrap the
nav
the main content withflex
As you have set
width: 20%;
, addflex-grow: 1;
to main content, so it can expand all the rest of the space.Put everything together