Responsive Web Design Projects - Build a Product Landing Page

Tell us what’s happening:
how can i add media query to my product landing page?

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.

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/103.0.0.0 Safari/537.36

Challenge: Responsive Web Design Projects - Build a Product Landing Page

Link to the challenge:

Hi!

Take a look at this w3schools article on media queries. It should help you write one.

It would also help if you shared your code.

To format your code, put three back tics at the start and end of your code. Or highlight the pasted code and press the button that looks like this </>.


<!DOCTYPE html>
<html>
  <head>
    <link rel="stylesheet" href="styles.css" />
    <link
      rel="stylesheet"
      href="https://use.fontawesome.com/releases/v5.8.1/css/all.css"
      integrity="sha384-50oBUHEmvpQ+1lW4y57PTFmhCaXp0ML5d60M1M7uH2+nqUivzIebhndOJK28anvf"
      crossorigin="anonymous"
    />
    <style>
    nav {position: fixed}
    display: flex;
    @media screen and (max-width: 600px) {
  body {
    background-color: olive;
  }
}
    </style>
  </head>
  <body>
    <div id="page-wrapper">
      <header id="header">
        <div class="logo">
          <img
            id="header-img"
            src="https://cdn.freecodecamp.org/testable-projects-fcc/images/product-landing-page-logo.png"
            alt="original trombones logo"
          />
        </div>

        <nav id="nav-bar">
          <ul>
            <li><a class="nav-link" href="#features">Features</a></li>
            <li><a class="nav-link" href="#how-it-works">How It Works</a></li>
            <li><a class="nav-link" href="#pricing">Pricing</a></li>
          </ul>
        </nav>
      </header>

      <div class="container"></div>

      <section id="hero">
        <h2>Handcrafted, home-made masterpieces</h2>
        <form id="form" action="https://www.freecodecamp.com/email-submit">
          <input
            name="email"
            id="email"
            type="email"
            placeholder="Enter your email address"
            required
          />
          <input id="submit" type="submit" value="Get Started" class="btn" />
        </form>
      </section>

      <div class="container">
        <section id="features">
          <div class="grid">
            <div class="icon"><i class="fa fa-3x fa-fire"></i></div>
            <div class="desc">
              <h2>Premium Materials</h2>
              <p>
                Our trombones use the shiniest brass which is sourced locally.
                This will increase the longevity of your purchase.
              </p>
            </div>
          </div>
          <div class="grid">
            <div class="icon"><i class="fa fa-3x fa-truck"></i></div>
            <div class="desc">
              <h2>Fast Shipping</h2>
              <p>
                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>
          </div>
          <div class="grid">
            <div class="icon">
              <i class="fa fa-3x fa-battery-full" aria-hidden="true"></i>
            </div>
            <div class="desc">
              <h2>Quality Assurance</h2>
              <p>
                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>
          </div>
        </section>
        <section id="how-it-works">
          <iframe
            id="video"
            height="315"
            src="https://www.youtube-nocookie.com/embed/y8Yv4pnO7qc?rel=0&amp;controls=0&amp;showinfo=0"
            frameborder="0"
            allowfullscreen
          ></iframe>
        </section>
        <section id="pricing">
          <div class="product" id="tenor">
            <div class="level">Tenor Trombone</div>
            <h2>$600</h2>
            <ol>
              <li>Lorem ipsum.</li>
              <li>Lorem ipsum.</li>
              <li>Lorem ipsum dolor.</li>
              <li>Lorem ipsum.</li>
            </ol>
            <button class="btn">Select</button>
          </div>
          <div class="product" id="bass">
            <div class="level">Bass Trombone</div>
            <h2>$900</h2>
            <ol>
              <li>Lorem ipsum.</li>
              <li>Lorem ipsum.</li>
              <li>Lorem ipsum dolor.</li>
              <li>Lorem ipsum.</li>
            </ol>
            <button class="btn">Select</button>
          </div>
          <div class="product" id="valve">
            <div class="level">Valve Trombone</div>
            <h2>$1200</h2>
            <ol>
              <li>Plays similar to a Trumpet</li>
              <li>Great for Jazz Bands</li>
              <li>Lorem ipsum dolor.</li>
              <li>Lorem ipsum.</li>
            </ol>
            <button class="btn">Select</button>
          </div>
        </section>
        <footer>
          <ul>
            <li><a href="#">Privacy</a></li>
            <li><a href="#">Terms</a></li>
            <li><a href="#">Contact</a></li>
          </ul>
          <span>Copyright 2016, Original Trombones</span>
        </footer>
      </div>
    </div>
  </body>
</html>

I’m sorry, but I have gone through it, and I don’t understand it

So, your media query is correctly written. The issue isn’t your media query, the problem is your css has syntax mistakes. You can use a css validator like this one to test css code.

Your display:flex has no selector. It needs to target part of your html.

You are also missing a bracket between your nav rule and media query rule. This will stop the media query working correctly.

<style>
    nav {position: fixed}
    display: flex;
    @media screen and (max-width: 600px) {
  body {
    background-color: olive;
  }
}
    </style>

I would also advise putting your css in the css file, not as part of the html inside a style element.

Using a separate css file is easier and standard practice. You’ve included a link to the css file in your html, so it is just a matter of moving the code to the css file.

Okay, what don’t you understand?

I will try to explain it to you. :slight_smile:

how to make my nav bar remain at the top of the viewport

Okay, I’ve found your forum post on that issue and will take a look.

You can link people directly to your forum posts. Copy the link from the search bar and past it into your reply. This makes it easier to find your post.

Please i have been trying, how can my nav bar remain at the top of the viewport?

I’m happy to help, but we need to talk about it on your topic post about the navbar issue.

This is the topic post about your navbar issue. I have asked for the css for your project.

https://forum.freecodecamp.org/t/responsive-web-design-projects-build-a-product-landing-page/538612/5

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