Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS CSS Layout Basics Controlling Layout with CSS Display Modes Positioning Elements Side-By-Side with Inline Display

What Am I Doing Wrong?

In the Positioning Elements Side-By-Side with Inline Display module in the CSS Layoot course, the instructor seems to be adding the various display rules inside of the media query, but when I do this the layout of my page does not change. However, if I write the rules outside of the media query everything works just fine. What am I doing wrong. I am going through the videos a second time to see if I can figure out what I missed, but can find nothing. If anyone encountered the same problem or has an insight into what I'm doing wrong, I would really appreciate the feedback.

I am having the same problem, I am on chrome, have the exact same code and it is not working. How did you resolve?

8 Answers

Can you post your code? both inside the media query and outside.

Thanks!

This is the code inside of the media query. it does not change the layout on the web page, but appears to be what the instructor is doing and instructing me to do.

@media (min-width:769px) {

    .wrap {
        min-height: calc(100vh - 89px);
    }

    .container {
        width: 80%;
        max-width: 1150px;
        margin: 0 auto;
    }

  .name,
  .main-nav,
  .main-nav li {
    display: inline;
  }
}

But if I place the inline rule outside of the media query, whether before or after it, the layout does what it is supposed to do, as shown in the video.

@media (min-width:769px) {

    .wrap {
        min-height: calc(100vh - 89px);
    }

    .container {
        width: 80%;
        max-width: 1150px;
        margin: 0 auto;
    }
}

 .name,
    .main-nav,
    .main-nav li {
      display: inline;
    }

Thanks for any insight you can provide.

Constance

Steven Parker
Steven Parker
229,771 Points

My guess is your window size doesn't fit the media query filter, which in this case is 769 pixels. When the code is inside the media query, try making your window wider than 769 pixels and see if you don't get the desired effect.

After all, changing behavior based on window/screen size is what media queries are for to begin with!

Thanks for your response, Steven. Unfortunately, when the inline rule is inside the media query resizing my window does not change anything; at all widow sizes the elements are displayed block. Resizing does change the layout when the rule is outside of the media query.

Also, I thought the point was to display everything as a block on smaller screens and display them inline on wider screens, so it doesn't make much sense that we are creating inline displays for smaller screens.

I guess for now I am just going to add the new rules outside of the media query where they seem to be working. I used media queries successfully in How to Build a Website, so I'm mystified by this problem.

Thanks again for your response.

Hazel Kenady
seal-mask
.a{fill-rule:evenodd;}techdegree
Hazel Kenady
Front End Web Development Techdegree Student 16,744 Points

Do you experience the same thing in other browsers? I experienced what you described when using Safari, which is the browser I use when working through Treehouse courses. When I checked the project for this video again in Chrome and Firefox, it worked exactly as it should with the display:inline in the Media Queries section of the CSS.

Thanks for your response, Hazel. I am using Firefox. I built a website in the How to Build a Website course and the media queries there worked just fine. I am stumped as to what's going on.

Matthew Schad
Matthew Schad
9,381 Points

I'm having this same issue currently. Have you come to a resolution?

No, I never resolved this issue. I even reached out to the instructor via Twitter and after I linked to this post with the code I never heard anything back. I ended up just completing those modules without have the responsive design work the way it is supposed to.

I am generally paranoid regarding Windows 10 so for now I'm blaming the problem on that though I am still using Firefox. Or maybe something is amiss in the code we are instructed to write. It remains a mystery to me.

Sorry I couldn't be of any help to you.

Matthew Schad
Matthew Schad
9,381 Points

It's a-okay, I appreciate the fast reply. I managed to get it to function in safari, but I also had errors in my code.

I never was able to resolve this problem. People suggested trying different browsers. Maybe you could try tweeting the instructor. I tried this, but never got a follow up response after linking him to this thread and the relevant code.

Okay, Thank you.

ywang04
ywang04
6,762 Points

Can you post your html? Have you checked your html part? Such as missing closing tag or wrong class name provided?