Nav section


#1

Hey guys,

I can't figure out why the nav section doesn't cover the entire width of the page

CSS INDEX :

/* Nav */
.nav {
width: 100%;
position: absoute;
}
.nav ul {
list-style: none;
margin: 0 auto;
padding: 30px 0;
text-align: center;
background: black;
width: 100%;
}
.nav li {
display: inline;
padding: 0px 15px 0px 15px;
color: white;

Any insights ? :slightly_smiling:


#2

Hi Julien,

Percentage measurements in CSS are relative; if .nav is inside of something only half as wide of the page, .nav will be 100% of that width - half the page. I think that's most likely the cause, your nav is probably inside something too narrow.

Would you mind copy/pasting all of your HTML and CSS code into here so we can see it?
Here's a post on how to format it so that it will be visible :slightly_smiling::


#3

Thanks for your feedback ! :slightly_smiling: Here we go :
HTML

<!DOCTYPE html>
<html>
  <head>
    <link href='https://fonts.googleapis.com/css?family=Roboto:400,300,500,100' rel='stylesheet' type='text/css'>
    <link rel='stylesheet' href='style.css'/>
  </head>
  <body>
    <div class="header">
      <div class="container">
        <h1>INNOVATION CLOUD</h1>
        <p>CONNECT YOUR IDEAS GLOBALY</p>
        <a href="#" class="btn">Learn More</a>
      </div>
    </div>

    <div class="nav">
      <div class="container">
        <ul>
          <li>Register</li>
        	<li>Schedule</li>
          <li>Sponsors</li>
          <li>About</li>
          <li>Contact</li>
        </ul>
      </div>
    </div>

    <div class="main">
      <div class="container">
        <img src="https://s3.amazonaws.com/codecademy-content/projects/innovation-cloud/cloud.svg">

        <h2>The Innovation Cloud Conference</h2>
        <p>Connect with the best minds across a wide range of industries to share ideas and brainstorm new solutions to challenging problems.</p>
        <p>Hear industry leaders talk about what worked (and what didn't) so that you can save time on your most challenging projects.</p>
         <p>Learn about the latest research and technologies that you can use immediately to invent the future.</p>
      </div>
      <div class="jumbotron">
        <div class="container">
    <h1>Stay Connected</h1>
    <p>Receive weekly insights from industry insiders</p>
    <a href="#" class="btn">Join</a>
        </div>
    </div>
		<div class="footer">
     <div class="container">
       <footer>
       <p>	&#169; Innovation Cloud Conference</p>
       </footer>
      </div>
      </div>
  </body>
</html>

CSS

html, body {
	margin: 0;
	padding: 0;
}

body {
	font-family: 'Roboto', sans-serif;
	font-weight: 100;
}

.container {
	margin: 0 auto;
	max-width: 940px; 
	padding: 0 10px; 
}


.header {
  height: 800px;
  text-align: center; 
  background: url(https://s3.amazonaws.com/codecademy-content/projects/innovation-cloud/bg.jpg);
  background-position: center;
  background-size: cover;
}

.header .container {
	position: relative;
	top: 200px;
  text-align: center;
  color: white;
  
}

.header h1 {
	font-size: 80px;
	line-height: 100px; 
	margin-top: 0;
	margin-bottom: 80px;
}

@media (min-width:850px) {
	.header h1 {
		font-size: 120px;
	}
}

.header p {
	font-weight: 500;
	letter-spacing: 8px;
	margin-bottom: 40px;
	margin-top: 0;
}
.btn {
	background: black;
  color: white;
  padding: 10px;
  font-size: 15px;
  text-decoration: none;
}
.btn:hover {
	background: #117bff;
	cursor: pointer; 
	transition: background .5s;  
}


/* Nav */
.nav {
	width: 100%;
  position: relative;
  border: solid red 2px;
}
.nav ul {
	list-style: none;
	margin: 0 auto; 
	padding: 30px 0;
	text-align: center; 
  background: black;
  width: 100%;
}
.nav li {
	display: inline;
  padding: 0px 15px 0px 15px;
  color: white;
}

/* Main */
.main .container {
	margin: 80px auto;
  text-align: justify;
}
.main img {
	float: left;
  width: 300px;
  margin-right: 20px;
}

/* Jumbotron */
.jumbotron {
	height: 600px; 
	text-align: right;
  background: url(https://s3.amazonaws.com/codecademy-content/projects/innovation-cloud/jumbotron_bg.jpg);
  background-size: cover;
  background-position: center;
  color: white;
}

.jumbotron .container {
	position: relative;
	top: 120px;
  float: right;
  margin-right: 100px;
}
/* Footer */
.footer { 
	font-size: 14px;
  background-color: black;
  position: absolute;
  width: 100%;
}
.footer p {
color: #fff;
font-size: 14px;
padding-bottom: 10px;
}


/* Media Queries */
@media (max-width: 500px) {
  .header h1 {
    font-size: 50px;
    line-height: 64px;
  }

  .main, .jumbotron {
    padding: 0 30px;
  }

  .main img {
    width: 100%;
  }
}

#4

Ok i have solved my problem.
I have made a mistake in my CSS code - i was not using the right CSS .nav ul li { }

.nav {
background-color: black;
}

.nav ul {
list-style: none;
margin: 0 auto;
padding: 30px 0;
text-align: center;
}

.nav ul li {
color: white;
display: inline;
margin-left: 100px;