#nav-bar at the top of viewport

Tell us what’s happening:
There is this task that says ’ Your #nav-bar should always be at the top of the viewport’. I already set the position fixed in my header so my nav-bar be always at the top, and I even tried to set it on my #nav-bar as well, but I am still unable to conclude that task, even tho my #nav-bar is always at the top of my viewport.

UPDATE: I checked the page source code of the website they provide us to make our website similar to (https://product-landing-page.freecodecamp.rocks/) and I noticed they haven’t set any positioning, such as position: fixed, on the #nav-bar, but they set it on the #header, which is the same thing I did.

Now, I copied the html and css code to check if their website would fullfill the ’ Your #nav-bar should always be at the top of the viewport’ task, and it didn’t, so I believe this is a problem of the task itself. I don’t know what should I do for some staff to fix this

Your code so far

WARNING

The challenge seed code and/or your solution exceeded the maximum length we can port over from the challenge.

You will need to take an additional step here so the code you wrote presents in an easy to read format.

Please copy/paste all the editor code showing in the challenge from where you just linked.

HTML

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Home page</title>
    <link rel="stylesheet" href="styles.css"/>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css">
  </head>
  <body>
    <header id='header'>
      <a href="index.html" class="logo"><img id='header-img' src="https://fabiosroadstop.com/wp-content/uploads/elementor/thumbs/Logotipo-01-oz75j78g8ee3o10sckagsjt2vs6dsqay2g19n6nd98.png" alt="" /></a>

      <nav id='nav-bar'>
        <ul class="nav-links">
          <li><a class="nav-link active" href="#home">HOME</a></li>
          <li><a class="nav-link" href="#about">ABOUT</a></li>
          <li><a class="nav-link" href="#menu">MENU</a></li>
        </ul>

        <div class="cart">
          <i id="menu-bar" class="fa fa-hamburger"></i>
          <a href="#"><i class="fa fa-shopping-bag"></i></a>
        </div>
      </nav>
    </header>

    <div id="home">
      <div class="board">
        <div class="separator-board">
          <div class="flex">
            <div class="line-board first-line"></div>
          </div>

          <div class="flex">
            <div class="line-board second-line"></div>
          </div>

          <div class="yellow">
            <h1>TODAY</h1>
          </div>
        </div>

        <div class="flex">
          <div class="line-red"></div>

          <div class="red is">
            <h2>is a</h2>
          </div>

          <div class="line-red"></div>
        </div>

        <div class="separator-board">
          <div class="yellow">
            <h1>good</h1>
            <h1>DAY</h1>
          </div>

          <div class="flex">
            <div class="line-board second-line"></div>
          </div>

          <div class="flex">
            <div class="line-board first-line"></div>
          </div>
        </div>
      </div>
    </div>

    <div class="flex container" id="about">
        <div class="col text">
            <div class="global-headline">
                <h2 class="sub-headline">
                    <span class="first-letter">D</span>iscover
                </h2>
                <h1 class="headline">our story</h1>
            </div>
            <p class="restaurant-description">Fabio’s Roadstop is a personal dream of mine, which came true. An American diner in conjunction with our own
                unique
                concept
                within which we value the quality of our produce and perform daily tests to improve the final results of our
                confections.
                All our attention is devoted to detail and therefore all our dishes are served in a careful and uniquely special
                way.
                We are a supportive team with the ambition to serve better and do better. We are in constant learning mode,
                testing,
                retrying, until we produce our products to the highest standard of quality. Our only goal is to offer something
                unique
                served with quality and great service.
                In our restaurant we want you to feel completely at home, to share happy moments whether they are with family or
                friends
                and to enjoy the best we have to offer, from the best drinks to a delicious meal.</p>
        </div>
        <div class="col">
            <video id='video' src="elementor-video"
                src="https://fabiosroadstop.com/wp-content/uploads/2020/11/Fabios-Roadstop-sem-Logo-Final-Updated.mp4" controls>
        </div>
      </div>
    </div>

	<div id="menu" class="main-font small-container">
        <h2 class="tittle">
            <span class="first-letter">M</span>enu
        </h2>
        <div class="row">
            <div class="col-4">
                <img
                    src="https://images.unsplash.com/photo-1584178639036-613ba57e5e39?crop=entropy&cs=srgb&fm=jpg&ixid=MnwxNDU4OXwwfDF8cmFuZG9tfHx8fHx8fHx8MTY0MDY4ODA0MA&ixlib=rb-1.2.1&q=85">
    
                <div class="name">
                    <h4>Burger</h4>
                    <i class='fas fa-cart-plus cart'></i>
                </div>
            </div>
    
            <div class="col-4">
                <img class="img"
                    src="https://images.unsplash.com/photo-1541592106381-b31e9677c0e5?crop=entropy&cs=srgb&fm=jpg&ixid=MnwxNDU4OXwwfDF8cmFuZG9tfHx8fHx8fHx8MTY0MDY4ODMwOA&ixlib=rb-1.2.1&q=85">
    
                <div class="name">
                    <h4>Fries</h4>
                    <i class='fas fa-cart-plus cart cart'></i>
                </div>
            </div>
    
            <div class="col-4">
                <img
                    src="https://images.unsplash.com/photo-1508254919937-d4a498e3366c?crop=entropy&cs=srgb&fm=jpg&ixid=MnwxNDU4OXwwfDF8cmFuZG9tfHx8fHx8fHx8MTY0MDY4ODgyMw&ixlib=rb-1.2.1&q=85">
    
                <div class="name">
                    <h4>Lemonade</h4>
                    <i class='fas fa-cart-plus cart'></i>
                </div>
            </div>
        </div>
	</div>

  <form id='form' action='https://www.freecodecamp.com/email-submit'>
  <h3>
    Tell us your email, so we know you would like to receive our promotions and discounts !
  </h3>
    <input id='email' type='email' placeholder='email' name='email'>
    <input id='submit' type='submit' placeholder='submit'>
  </form>
	
	<footer>
        <div class="box-container">
            <div class="box">
                <h3>Contact info</h3>
                <p><i class="fa fa-map-marker"></i>Rua Dr. Manuel de Arriaga
                Edf. Mar Salgado, Lote 1
                Loja E, 8365-140, Armação de Pêra</p>
                <p><i class="fa fa-envelope"></i>fabio@fabiosroadstop.com</p>
                <p><i class='fa fa-phone'></i>(+351) 282 317 025</p>
            </div>

            <div class="box">
                <h3>Opening hours</h3>
                <p>Tuesday to Saturday from 8:00 to 22:30</p>
            </div>
            
            <div class="box">
                <h3>Follow us</h3>
                <a href="">Instagram</a>
                <a href="">Facebook</a>
                <a href="">Youtube</a>
                <a href="https://www.tripadvisor.pt/Restaurant_Review-g189113-d17755337-Reviews-Fabio_s_RoadStop-Armacao_de_Pera_Faro_District_Algarve.html">TripAdvsor</a>
            </div>
        </div>
        <hr>
        <p class="credit">Fabio's Roadstop - All rights reserved</p>
    </footer>
  </body>
  <script>
    "use strict";

const burger = document.querySelector("#menu-bar");
const navLinks = document.querySelector(".nav-links");
const link = document.querySelectorAll(".nav-link");

burger.addEventListener("click", function () {
  burger.classList.toggle("fa-times");
  navLinks.classList.toggle("nav-toggle");
});

link[0].addEventListener("click", function () {
  link[0].classList.add("active");

  if (link[0].classList.contains("active")) {
    link[1].classList.remove("active");
    link[2].classList.remove("active");
    link[3].classList.remove("active");
  }
});

link[1].addEventListener("click", function () {
  link[1].classList.add("active");

  if (link[1].classList.contains("active")) {
    link[0].classList.remove("active");
    link[2].classList.remove("active");
    link[3].classList.remove("active");
  }
});

link[2].addEventListener("click", function () {
  link[2].classList.add("active");

  if (link[2].classList.contains("active")) {
    link[0].classList.remove("active");
    link[1].classList.remove("active");
    link[3].classList.remove("active");
  }
});

  </script>
</html>

CSS

@import url("https://fonts.googleapis.com/css2?family=Source+Sans+Pro:wght@400;900&display=swap");
@import url("https://fonts.googleapis.com/css2?family=Herr+Von+Muellerhoff&display=swap");
@import url("https://fonts.googleapis.com/css2?family=Dancing+Script&display=swap");
@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@300&display=swap");

:root {
  --main-font: "Souce Sans Pro", sans-serif;
  --secondary-font: "Herr Von Muellerhoff";
  --body-font: "Cabin", sans-serif;
  --main-font-color-dark: #252525;
  --secondary-font-color: #ffc477;
  --body-font-color: #515151;
  --animation-color: #fff;

  /* CSS HEX */
  --rich-black-fogra-29: #101417ff;
  --gold-metallic: #d5ad3fff;
  --ruby-red: #942427ff;
  --gray-web: #807e7fff;
  --rich-black-fogra-29-2: #101417ff;

  /* CSS HEX */
  --black: #000000ff;
  --azure: #0080ffff;
  --dim-gray: #69656cff;
  --cg-red: #e6362eff;
  --verdigris: #00aaaaff;
  --gold-web-golden: #fcd40bff;
  --lemon-yellow: #faed3dff;
  --yellow: #f7ca3e;
}

html {
  scroll-behavior: smooth;
  overflow-x: hidden;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  text-decoration: none;
  list-style-type: none;
  outline: none;
  border: none;
  transition: all 0.2s linear;
  /* font-family: "Poppins", sans-serif; */
}

/* HEADER */

header {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1000;
  width: 100%;
  background-color: #fff;
  padding: 0.8rem 14%;
  box-shadow: 0 0.3rem 0.2rem rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo img {
  height: 5.5rem;
}

#nav-bar {
  display: flex;
  font-size: 1.1rem;
}

#nav-bar .nav-links {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

#nav-bar .nav-links li {
  margin-right: 2rem;
}

.nav-link {
  color: #666;
}

.cart {
  font-size: 1.3rem;
}

.cart i {
  color: #666;
}

.active {
  color: var(--yellow);
}

#menu-bar {
  display: none;
}
/* HEADER END */

/* HOME */

#home {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 85vh;
  background: #54a8c9;
  margin-top: 15vh;
}

.board {
  font-family: "Dancing Script", cursive;
  border: 10px solid;
  width: 23%;
  padding: 50px;
  text-align: center;
  font-size: 2vw;
}

.flex {
  display: flex;
  align-items: center;
  justify-content: center;
}

.line-board {
  width: 100%;
  height: 0.25rem;
  background-color: var(--cg-red);
  margin: 5px;
}

.first-line {
  width: 75%;
}

.second-line {
  width: 85%;
}

.yellow {
  color: var(--lemon-yellow);
}

.line-red {
  background-color: var(--cg-red);
  width: 100%;
  height: 0.25rem;
  margin: 5px -2px 0 -2px;
}

.red {
  color: var(--cg-red);
  width: 50%;
  flex: none;
}

/* HOME END */

/* ABOUT */

.container {
  font-size: 1.6vw;
  height: 100vh;
  display: flex;
  justify-content: center;
  padding: 0 40px;
}

.col {
  flex-basis: 50%;
  margin: 0 10px;
}

.text {
  margin-top: -10.75vw;
}

.global-headline {
  text-align: center;
  font-family: var(--secondary-font);
  color: var(--lemon-yellow);
}

.headline {
  font-size: 4.5vw;
  font-weight: 100;
  letter-spacing: -1px;
  margin-top: -3.125vw;
}

.sub-headline {
  font-size: 3vw;
  font-weight: 100;
  letter-spacing: -1px;
}

.first-letter {
  text-transform: uppercase;
  font-size: 4vw;
}

video {
  width: 100%;
}

/* ABOUT END */

/* MENU */

.tittle {
  margin: 0 0 17vh;
  font-size: 4.5rem;
  font-family: var(--secondary-font);
  color: var(--gold-web-golden);
  font-weight: 100;
  line-height: 0.6;
  letter-spacing: 2px;
  text-align: center;
}

.tittle .first-letter {
  text-transform: uppercase;
  font-size: 4.3rem;
}

.small-container {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  margin: auto;
  padding-bottom: 10vh;
}

.row {
  display: flex;
  justify-content: center;
  align-items: center;
}

.col-4 {
  min-width: 20vw;
  margin-bottom: 50px;
  transition: transform 0.5s;
}

.col-4 img {
  width: 15vw;
}

.name {
  display: flex;
  justify-content: space-between;
  width: 15vw;
}

.cart:hover {
  cursor: pointer;
  color: var(--lemon-yellow);
}

.col-4:hover {
  transform: translateY(-5px);
}
/* MENU END */

/* FORM */

form {
  font-size: 1.6vw;
  text-align: center;
  padding: 10px 50px 50px;
}

form input {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 10px auto;
}

#email {
  padding: 10px;
  border: 2px solid var(--lemon-yellow);
}

#submit {
  cursor: pointer;
  padding: 10px;
  background: var(--lemon-yellow);
  border: 1px solid white;
  border-radius: 10px;
  color: white;
}

#submit:hover {
  color: var(--lemon-yellow);
  background: white;
  border: 1px solid var(--lemon-yellow);
}

/* FOOTER */

footer {
  background: #000;
  padding: 1rem 7%;
  font-family: poppins;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

footer .box-container {
  display: flex;
  justify-content: flex-end;
}

footer .box-container .box {
  color: #fff;
  flex-basis: 30%;
  padding: 0 10px;
}

footer .box-container .box p {
  color: #eee;
  padding: 1rem 0;
}

footer .box-container .box a {
  color: #eee;
  padding: 1rem 0;
  display: block;
}

footer .box-container .box a:hover {
  color: var(--lemon-yellow);
}

footer .box-container .box p i {
  padding-right: 0.5rem;
  color: var(--lemon-yellow);
}

footer hr {
  border: none;
  background: #b5b5b5;
  height: 1px;
  margin: 20px 0;
}

.credit {
  text-align: center;
  color: white;
}
/* FOOTER END */

@media screen and (max-width: 770px) {
  /* NAV */

  #nav-bar .nav-links {
    border-top: 5px solid black;
    position: fixed;
    top: 7rem;
    left: 0;
    width: 100%;
    background: var(--lemon-yellow);
    display: flex;
    flex-flow: column;
    transform: scaleY(0);
    transform-origin: top;
    opacity: 0;
  }

  #nav-bar .nav-links.nav-toggle {
    transform: scaleY(1);
    opacity: 1;
  }

  #nav-bar .nav-links li {
    margin-right: 2rem;
    padding: 10px;
  }

  .cart {
    display: flex;
    font-size: 1.4rem;
  }

  .cart i {
    margin: 0 5px;
  }

  #menu-bar {
    display: block;
    margin-top: 3px;
  }

  .fa-times {
    transform: rotate(180deg);
  }

  /* NAV END */

  .board {
    border: 8px solid;
    width: 32vw;
    padding: 45px;
  }

  /* ABOUT */

  .container {
    height: 80vh;
  }

  .headline {
    font-size: 5.5vw;
  }

  .sub-headline {
    font-size: 4vw;
  }

  .first-letter {
    text-transform: uppercase;
    font-size: 5vw;
  }

  video {
    width: 100%;
  }
  
  .col-4 {
  min-width: 25vw;
  margin-bottom: 50px;
  transition: transform 0.5s;
  }

  .col-4 img {
    width: 20vw;
  }
  
  .name {
  display: flex;
  justify-content: space-between;
  width: 20vw;
}

/* FORM */

form {
  font-size: 2vw;
}
  /* FOOTER */

  footer {
    font-size: 2vw;
  }
}

@media screen and (max-width: 430px) {
  .board {
    width: 52vw;
    padding: 40px;
    font-size: 3.2vw;
  }

  /* ABOUT */

  .container {
    flex-flow: column;
    font-size: 2.7vw;
    height: 70vh;
    padding: 0 9vw;
    margin-top: 10vh;
  }

  .col {
    flex-basis: 50%;
    display: flex;
    align-items: center;
    flex-direction: column;
  }

  .text {
    padding: 0 0 30px;
  }

  .headline {
    font-size: 8.5vw;
    font-weight: 100;
    letter-spacing: -1px;
    margin-top: -5.125vw;
  }

  .sub-headline {
    font-size: 7vw;
    font-weight: 100;
    letter-spacing: -1px;
  }

  .first-letter {
    text-transform: uppercase;
    font-size: 8vw;
  }

  video {
    width: 100%;
  }
}


Replace these two sentences with your copied code.
Please leave the ``` line above and the ``` line below,
because they allow your code to properly format in the post.

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.67 Safari/537.36

Challenge: Build a Product Landing Page

Link to the challenge:

I believe position: fixed needs to be on the <nav> itself, not the <header>.

1 Like

bbsmooth’s suggestion might be it. Or it might be that you need to add positioning to this in your css:

The test requires the nav to have positioning that places it so it’s always at the top of the page. It doesn’t have any positioning. That might be why the test isn’t passing.

I have tried that. I set both #header and #nav-bar to position: fixed; and even tried setting only the #nav-bar to position: fixed, and still haven’t been able to solve this task :confused:

The test seems to require axis positions (top, right, bottom, left) that place the nav-bar always at the top of the page. I’ve contributed to other threads fellow members of this site posted having a similar experience as you’re having. That’s what did it for them.

position: fixed; by it self doesn’t “fix” an element to the top by default it “fixes” it wherever it is in the code. If there’s content in the code above, below, or to one side of it according to how the code is when the view port is resized or scrolled an object that’s ‘position: fixed;’ is going to move around staying away from the other content around it.

It needs axis positions too.

Check out the “try it yourself” things at the above link.
Grab the separator bar on the bottom and move it left or right to resize the view ports to see what the different position: values do.

1 Like

Alright, that’s the solution. We have to set axis positions and we have to set all of them. Thank you very much :grin:

I’m not 100% positive the test will accept doing just this but in a real-life coding situation to make an element always be on top of the page we only need:

.class_name {
   position: absolute;
   top: 0px;
}

If layers argue with and bleed into each other we can give both elements a z-index value. Use a CSS reference to learn what z-index does. If you’re going to be coding websites this way in the future, regardless of the reason you’re doing it, you’re going to use z-index at some point.

I see, I will study more about it then, thanks for the advice.

About the test, I passed it and the only thing I changed was by adding the axis positions of right and bottom, like the following:

header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 540;
  z-index: 1000;
  width: 100%;
  background-color: #fff;
  padding: 0.8rem 14%;
  box-shadow: 0 0.3rem 0.2rem rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

Which means, as you said, I needed to especify the axis positions (top, right, bottom, left). No changes were made on the #nav-bar.

Interesting to know it passed without using a unit of measurement suffix. I thought those were required. I was apparently wrong, but I’ll continue to use them anyway. It probably is best to use a unit suffix with the values margin: 10px;.

Did you try only top: 0px; or margin-top: 0; ?
It might accept that and pass it. I’m curious to know. If you don’t want to share that answer I’ll get to that part of testing the tests eventually.

I used both axis positions and unit suffix (top, right, bottom, left / margin, …), but it only passed when I used the axis positions

Maybe it might be possible they’ll adjust the tests here so it does accept the 4 margin values since that method is included on reference sites.

i tried all and it still dont work with me!!

Share your code, so we can help

Hello,

I have the same problem : my header is fixed (for mobile/tablet/computer screen) - I use the fixed position - The problem seems to come from the img → Every time I push the button “Run the test” my image is redimensioning and become spontaneously bigger than expected.

Here is my HTML code :

<!DOCTYPE html>
<html>

<head>
  <link rel="stylesheet" href="styles.css">
</head>

<body>
  <header id="header">
    <img id="header-img" src="https://cdn.freecodecamp.org/testable-projects-fcc/images/product-landing-page-logo.png"
      alt="Logo Original Trombones">
    <nav id="nav-bar">
      <div><a class="nav-link" href="#features">Features</a></div>
      <div><a class="nav-link" href="#video-section">How It Works</a></div>
      <div><a class="nav-link" href="#pricing">Pricing</a></div>
    </nav>
  </header>
  <main>
    <section id="title">
      <h1 id="header-title">Handcrafted, home-made masterpieces</h1>
      <form id="form" action="https://www.freecodecamp.com/email-submit">
        <input id="email" type="email" name="email" placeholder="Enter your email address">
        <input id="submit" type="submit" name="submit" value="Get started">
      </form>
    </section>
    <section id="features">
      <article class="feature">
        <svg class="feature-logo" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="60" height="60"><path fill="none" d="M0 0h24v24H0z"/><path d="M12 23a7.5 7.5 0 0 0 7.5-7.5c0-.866-.23-1.697-.5-2.47-1.667 1.647-2.933 2.47-3.8 2.47 3.995-7 1.8-10-4.2-14 .5 5-2.796 7.274-4.138 8.537A7.5 7.5 0 0 0 12 23zm.71-17.765c3.241 2.75 3.257 4.887.753 9.274-.761 1.333.202 2.991 1.737 2.991.688 0 1.384-.2 2.119-.595a5.5 5.5 0 1 1-9.087-5.412c.126-.118.765-.685.793-.71.424-.38.773-.717 1.118-1.086 1.23-1.318 2.114-2.78 2.566-4.462z" fill="rgba(230,126,34,1)"/></svg>
        <div class="feature-content">
          <h1 class="feature-title">Premium Materials</h1>
          <p class="feature-desc">Our trombones use the shiniest brass which is sourced locally. This will increase the longevity of your
            purchase.</p>
        </div>
      </article>
      <article class="feature">
        <svg class="feature-logo" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="60" height="60"><path fill="none" d="M0 0h24v24H0z"/><path d="M8.965 18a3.5 3.5 0 0 1-6.93 0H1V6a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2h3l3 4.056V18h-2.035a3.5 3.5 0 0 1-6.93 0h-5.07zM15 7H3v8.05a3.5 3.5 0 0 1 5.663.95h5.674c.168-.353.393-.674.663-.95V7zm2 6h4v-.285L18.992 10H17v3zm.5 6a1.5 1.5 0 1 0 0-3.001 1.5 1.5 0 0 0 0 3.001zM7 17.5a1.5 1.5 0 1 0-3 0 1.5 1.5 0 0 0 3 0z" fill="rgba(230,126,34,1)"/></svg>
        <div class="feature-content">
          <h1 class="feature-title">Fast Shipping</h1>
          <p class="feature-desc">We make sure you recieve your trombone as soon as we have finished making it. We also provide free returns if
            you are not satisfied.</p>
        </div>
      </article>
      <article class="feature">
        <svg class="feature-logo"  xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="60" height="60"><path fill="none" d="M0 0h24v24H0z"/><path d="M4 7v10h14V7H4zM3 5h16a1 1 0 0 1 1 1v12a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1zm18 4h2v6h-2V9z" fill="rgba(230,126,34,1)"/></svg>
        <div class="feature-content">
          <h1 class="feature-title">Quality Assurance</h1>
          <p class="feature-desc">For every purchase you make, we will ensure there are no damages or faults and we will check and test the pitch
            of your instrument.</p>
        </div>
      </article>
    </section>
    <section id="video-section">
      <iframe id="video" height="315" src="https://www.youtube.com/embed/y8Yv4pnO7qc"
        title="YouTube video player" frameborder="0"
        allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen>
      </iframe>
    </section>
    <section id="pricing">
      <article class="price-article">
        <h1>Tenor Trombone</h1>
        <h2>$600</h2>
        <p>Lorem ipsum.</p>
        <p>Lorem ipsum.</p>
        <p>Lorem ipsum dolor.</p>
        <p>Lorem ipsum.</p>
        <div>SELECT</div>
      </article>
      <article class="price-article">
        <h1>Bass Trombone</h1>
        <h2>$900</h2>
        <p>Lorem ipsum.</p>
        <p>Lorem ipsum.</p>
        <p>Lorem ipsum dolor.</p>
        <p>Lorem ipsum.</p>
        <div>SELECT</div>
      </article>
      <article class="price-article">
        <h1>Valve Trombone</h1>
        <h2>$1200</h2>
        <p>Plays similar to a Trumpet</p>
        <p>Great for Jazz Bands</p>
        <p>Lorem ipsum dolor.</p>
        <p>Lorem ipsum.</p>
        <div>SELECT</div>
      </article>
    </section>
    <footer id="footer">
      <div id="footer-info">
        <p>Privacy</p>
        <p>Terms</p>
        <p>Contact</p>
      </div>
      <div id="footer-copyright">
        <p>Copyright 2016, Original Trombones</p>
      </div>
    </footer>
  </main>
</body>

</html>

Here is the CSS code :

@font-face {
  font-family: "Merriweather";
  src:url('https://fonts.googleapis.com/css2?family=Merriweather:wght@300');
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body{
  font-family: "Merriweather", sans-serif;
  display: flex;
  flex-direction: column;
  margin: 0;
  background-color: rgba(238, 238, 238, 1);
}

#header {
  /*Fixed menu - start*/
  position:fixed;
  background-color: rgba(238, 238, 238, 1);
  z-index: 1;
  top: 0;
  min-height: 85px;
  /*Fixed menu - end*/

  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

/*if not larger than 769px*/
@media screen and (max-width: 769px) {
  #header {
    /*Fixed menu - start*/
    position : fixed;
    background-color: rgba(238, 238, 238, 1);
    z-index: 1;
    top: 0;
    min-height: 190px;
    /*Fixed menu - end*/

    display: flex;
    flex-direction: column;
  }
}

#img{
  width: 60vw;
}

#header-img{
  width: 100%;
  height: 100%;
  max-width: 300px;
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
}

#nav-bar {
  display: flex;
  flex-direction: row;
  width: 50%;
  justify-content: space-around;
}

#nav-bar div {
  text-align: center;
}

.nav-link {
  text-decoration: none;
  color: rgba(0, 0, 0, 1);
  padding: 5px 10px;
}

.nav-link:hover {
  background-color: rgba(255, 190, 0, 1);
}

@media screen and (max-width: 769px) {
  #nav-bar {
    display:flex;
    flex-direction: column;
    width: 100%;
  }

  #nav-bar div {
    padding: 0.5em 0;
    background-color: rgba(0, 0, 0, 0.1);
    width: 100%;
    text-align: center;
  }

  #nav-bar div:hover {
    background-color: rgba(255, 190, 0, 1);
  }
}

#header-title{
  font-size:2em;
  width: 100%;
  text-align: center;
}

main{
  margin-top: 85px;
  display:flex;
  flex-direction: column;
  max-width: 1000px;
  width: 100%;
}

@media screen and (max-width: 769px) {
  main {
    position: absolute;
    top: 190px;
  }
}

#title {
  display: flex;
  flex-direction:column;
  justify-content: center;
  align-items: center;
  width: 100%;
  margin-bottom: 25px;
}

#form {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

#email {
  height: 1.5em;
  width: 40%;
  margin: 10px 0px;
}

#email::placeholder{
  font-family: "Merriweather", sans-serif;
  font-size: 1em;
  padding : 1px 3px;
}

#submit{
  background-color: rgba(255, 190, 0, 1);
  border: none;
  color: rgba(0, 0, 0, 1);
  text-decoration: none;
  padding: 5px 10px;
  font-size: 1.5em;
  text-transform: capitalize;
  text-align: center;
  display: inline-block;
  font-weight: 700;
  transition-duration: 2s;
  transition-property: background-color;
  cursor: pointer;
}

#submit:hover{
  background-color: rgba(255,160,0,1);
}

#features{
  display:flex;
  flex-direction: column;
  margin: 50px 0;
}

.feature{
  display:flex;
  flex-direction: row;
  align-items: center;
}

.feature-logo{
  width: 200px;
}

.feature-content{
  width: 100%;
}

.feature-title{
  margin-bottom: 0px;
}

.feature-desc{
  margin-top: 5px;
}


#video-section {
  margin: 0 auto;
  max-width: 560px;
  width: 100%;
}

#video {
  width: 100%;
}

#pricing {
  display:flex;
  flex-direction: row;
  justify-content: center;
  margin: 25px 0px;
}

@media screen and (max-width: 769px) {
  #pricing {
    display: flex;
    flex-direction: column;
    align-items: center;
  }
}

.price-article{
  display: flex;
  flex-direction : column;
  width: 300px;
  margin: 5px 10px;
  border: 1px solid black;
}

.price-article > h1{
  background-color: rgba(0, 0, 0, 0.1);
  padding: 1em 0;
  margin: 0;
  text-align: center;
}

.price-article > h2{
  text-align: center;
}

.price-article p{
  text-align: center;
  margin: 0.5em;
}

.price-article > div{
  background-color : rgba(255, 190, 0, 1);
  color: rgba(0, 0, 0, 1);
  padding: 10px 25px;
  font-size: 1.5em;
  text-transform: capitalize;
  text-align: center;
  vertical-align: middle;
  font-weight: 700;
  transition-duration: 2s;
  transition-property: background-color;
  cursor: pointer;
  margin: 10px auto 5px auto;
}

.price-article > div:hover{
  background-color: rgba(255,160,0,1);
}

#footer{
  background-color: rgba(0, 0, 0, 0.1);
  display:flex;
  flex-direction: column;
}

#footer-info{
  display:flex;
  flex-direction: row;
  justify-content: end;
}

#footer-info p{
  margin: 15px 10px 5px 5px;
}

#footer-copyright{
  display:flex;
  justify-content: end;
}

#footer-copyright p{
  margin: 5px 10px 10px 0px;
}

Do you have an idea on what wrong is ?

Thanks a lot for your help.

Hello, sorry for the late reply. About your code, I just checked it and there are many tasks still to be done, such as defining the id’s of certain sections, like the main section and others.

About the header, it’s everything alright, the thing is you don’t have to repeat the same code you used for the desktop view to the device’s view. What the exercises wants you to do to solve the problem of this topic is to set the axis positions (top, right, bottom, let) after you set the position property of your header. e.g. :

#header {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
}

Hello! Thanks for this answer. I finally resolved my problem. I reworked on my code based on your comments and this project was accepted.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.