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 Techniques Float Layout Mobile First Layout

Ehsan Raza
Ehsan Raza
263 Points

Method is not similar as this video but the result is the same.

Even though I have same result as expected, the method or technique for this did not go exactly as expected. My question is, is it Ok if i can achieve the same result but a different approach. I wanted to do exactly as this video says but at some stages i had to come with an alternative. So what's your thoughts?

Hook us up with some code... I would love to see what is happening... Good Luck and Happy New Year

Ehsan Raza
Ehsan Raza
263 Points

Here is the CSS:

'''/* General Styles ================================ */

*{ box-sizing: border-box; } a{ text-decoration: none; } h1, h2, h3{ text-align: center; }

/* Layout Element Colors ================================ */

.main-header { background-color: #384047; } .main-logo a { background-color: #5fcf80; } .main-nav a { background-color: #3f8abf; } .main-banner { background-color: #d79255; } .primary-content { background-color: #caebf6; } .secondary-content { background-color: #bfe3d0; } .main-footer { background-color: #b7c0c7; } .extra-content { background-color: #f7d0b9; }

/* Header Layout Styles ================================ */

.main-header{ padding: 20px; color: white; } .main-logo{ margin-top: 0; margin-bottom: 0;
font-size: 2.5em; } .main-logo a, .main-nav a{ display: block; padding: 5px 20px; text-align: center; border-radius: 5px; font-weight: bold; color: white;

} .main-nav li{ margin: 15px auto auto; width: 90%; } .main-footer{ text-align: center; padding: 20px; border-top: 5px solid #747474; }

/* Column Layout ================================ */

.col{ display: block; padding: 20px; } .main-banner, .extra-content{ display: none; }

/* Imagery ================================ */

.feat-img{ width: 100%; margin: 10px 0 10px 0; padding: 5px; border: 1px solid; }

/* Media Queries ================================ */

@media (min-width: 768px){

/* Header Layout Styles ================================ */

.main-wrapper{ width: 90%; margin: auto auto; } html, body, .main-wrapper, .content-row, .col{ height: 100%; } .main-header{ float: left; width: 100%; } .main-logo a{ float: left;
} .main-nav a{ float: left; padding: 5px 20px; margin-right: 15px; } .main-logo a{ margin-right: 50px; }

/* Column Layout Styles ================================ */

.col{ float: left; width: 30%; } .group::after{ display: table; content: " "; clear: both; } .primary-content{ width: 40%; } .main-banner, .extra-content{ display: inline-block; } .main-banner{ width: 100%; } .main-banner p{ text-align: center; }

/* Imagery Styles ================================ */

.feat-img{ width: 60%; float: left; margin: 0 10px 10px 0; padding: 5px; border: 1px solid; } }'''

Code looks okay. Without seeing the html or site; I got nothing. Do you have codepen?

Ehsan Raza
Ehsan Raza
263 Points

I'm using Notepadd++ so it will not not be pasted the right way.

Ehsan Raza
Ehsan Raza
263 Points

yep here it is:

'''<!DOCTYPE html> <html> <head> <title>Positioning Schemes</title> <meta name="viewport" content="width=device-width"> <link rel="stylesheet" href="css/normalize.css"> <link rel="stylesheet" href="css/style.css"> </head> <body> <div class="main-wrapper"> <header class="main-header"> <h1 class="main-logo"><a href="#">Logo</a></h1> <ul class="main-nav group"> <li><a href="#">Link 1</a></li> <li><a href="#">Link 2</a></li> <li><a href="#">Link 3</a></li> <li><a href="#">Link 4</a></li> </ul> </header> <!-- <div class="main-banner"> <h1>This is the Main Banner Heading</h1> <p>Andouille pork chop pancetta drumstick ground round beef ribs swine brisket ham.</p> </div> --> <div class="content-row group"> <div class="extra-content col"> <h3>Extra Content</h3> <p>Filet mignon turkey flank doner strip steak. Frankfurter ham hock turkey, venison sirloin pig chuck shank capicola hamburger doner spare ribs boudin.</p> <hr> <p> Drumstick bresaola meatloaf ham hock salami tri-tip landjaeger beef filet mignon biltong boudin turkey.</p> </div> <div class="primary-content col"> <h2>Primary Content</h2> <img class="feat-img" src="http://lorempixel.com/400/300" /> <p>Bacon ipsum dolor sit amet chicken pork ground round brisket corned beef ball tip shank tail salami filet mignon ham hock pork belly venison shankle. Pig kielbasa drumstick sausage pork chop boudin. Chicken t-bone salami pork chop, beef ribs kevin ham tri-tip beef venison biltong brisket.</p> <p>Venison strip steak meatball chicken, brisket prosciutto sirloin. Capicola drumstick brisket tri-tip salami. Chicken beef jerky, tail turkey prosciutto cow ham sirloin boudin tenderloin. Meatloaf tri-tip turducken brisket andouille, pork belly corned beef fatback hamburger.</p> </div> <div class="secondary-content col"> <h3>Secondary Content</h3> <p>Strip steak tenderloin kevin swine meatloaf capicola, doner beef turducken pancetta corned beef pork loin shoulder.</p> <hr> <p>Pork filet mignon leberkas, tail swine venison pancetta turkey shoulder brisket chalkers likes hamburgers.</p> </div> </div> <footer class="main-footer"> <p>©2014 Example Layout</p> </footer> </div> </body> </html>'''

Ehsan, this is totally cool. I just had notepad++ open. It is great to know we are using the app, it's good for comparing code. I think your code is legit and I agree with Dylan. It was great trying to help. Good luck on your learning.

3 Answers

You are doing much better than I did when I started out. In fact, I just learned how to do it my self. I found this post really helped. If you have any questions or need positive feedback look me up on twitter. @masterjedijohn

Ehsan Raza
Ehsan Raza
263 Points

Oh thanks so much. Now i can go ahead and make the use of it :)

Dylan Macnab
Dylan Macnab
24,861 Points

There are always multiple ways to solve most coding problems. I think it's okay if you're coming up with your own solution as long as you understand or can explain why you are doing it the way you chose over the way it's done in the video. Hope that helps

Ehsan Raza
Ehsan Raza
263 Points

Yep I thought so. Thanks.

Ehsan Raza
Ehsan Raza
263 Points

John Mutch, Do you know any way i can paste the CSS in forums in the correct format just like html? I had recently joined the Teamtreehouse so uno...