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 Responsive Layout

David McEnnerney
seal-mask
.a{fill-rule:evenodd;}techdegree
David McEnnerney
Front End Web Development Techdegree Student 2,377 Points

Should i be using Flexbox in my project?

Should i be using Flexbox in this responsive layout project. I cant remember learning it in the course content previous, and have already written and styled the code for the mobile first without it.

I have since watched the video links and read about flexbox as I saw the link in the project resources but I cant seem to get my head around it after just figuring out floats etc. I tried to implement it in my project but without starting again i cant seem to make it work?

Is it ok to finish this project without flexbox and try and learn/implement it more in future work?

3 Answers

Konstantin Kovar
Konstantin Kovar
16,003 Points

Flexboxes are new in CSS 3.

Imho flexboxes have not yet really caught on because there are no big, widely used frameworks for them yet, but once they get bigger and better, I think they will slowly become the main way to layout things, but I might be wrong.

David McEnnerney
seal-mask
.a{fill-rule:evenodd;}techdegree
David McEnnerney
Front End Web Development Techdegree Student 2,377 Points

You are most certainly correct, i thought I had tried this but had not also changed it in the initial flex declaration. Thanks for your help!

Erik Nuber
Erik Nuber
20,629 Points

Here is a site that does a great job explaining flexbox. During the courses you are just being shown different layout skills. It is up to you which you would like to use. Flexbox would make a responsive navbar easier to create and maintain but, there is nothing wrong with using inline-block, block or something else.

The flexbox properties can be used however you like and can be combined as well.

https://css-tricks.com/snippets/css/a-guide-to-flexbox/

David McEnnerney
seal-mask
.a{fill-rule:evenodd;}techdegree
David McEnnerney
Front End Web Development Techdegree Student 2,377 Points

Thanks for your answer and the page is very usefull.

I still cannot seem to make a nav convert from column to row though. my html is set out like this:

<header id="home"> <h1>David McEnnerney</h1>

    <nav class="main_nav">
        <ul>
            <li><a href="#home">HOME</a></li>
            <li><a href="#portfolio">PORTFOLIO</a></li>
            <li><a href="#contact">CONTACT</a></li>
        </ul>
    </nav>

</header>

and initially set the css out like this:

header, .main_nav { display: flex; flex-direction: column; text-align: center; }

but in my media query when i want to set the nav elements to row they stay stacked as if in column?

@media (min-width: 769px) {

.main_nav { flex-direction: row; } }

Cant figure out why this is happening?

Konstantin Kovar
Konstantin Kovar
16,003 Points

I'm pretty sure you have to use the <ul> selector in your css. Right now you're just telling your nav how to align the <ul>, but you want to tell the <ul> how to align the <li>, amarite?