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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Michal Broniewicz](https://uploads.teamtreehouse.com/production/profile-photos/3192632/micro_av.jpg)
Michal Broniewicz
6,681 PointsColumn Layout do not fit.
Im trying to follow up with the video where Guil is showing column layout with inline-blocks. I know about margins I checked my font size and still i cant make them be displayed side by side. I have to change margin to like -50px to make it happen but its not looking like i would like it to be.. here is my css
/* Page Styles
================================ */
body {
font: normal, sans-serif;
color: #222;
background-color: #edeff0;
max-width: 90%;
margin: auto;
}
.main-wraper li,
.main-logo,
.main-nav {
display: inline;
padding: 10px 20px;
border-radius: 5%;
}
.main-nav li {
margin-right: 10px;
}
.main-header {
padding: 20px;
white-space: nowrap;
}
.main-logo {
margin-right: 50px;
}
/* Column Layout
================================ */
.col {
display: inline-block;
padding: 20px;
margin-right: -5px;
}
.primary-content {
width: 60%;
}
.secondary-content {
width: 40%;
}
div {
max-width: 100%;
}
Do you know what should i do to make it?
1 Answer
![Ryan Field](https://uploads.teamtreehouse.com/production/profile-photos/2892162/micro_ryan3.jpg)
Ryan Field
Courses Plus Student 21,242 PointsSo, what's happening here is that under normal circumstances (i.e. browser defaults), divs and other elements are given default padding, which is calculated on top of the dimensions you specify. So, while you may be telling one div to be 60% and the other to be 40%, there is still padding that is being automatically added on top of your percentages, which causes them too large to sit on one line together.
To fix this (and I always do this in my projects to avoid head-scratching scenarios like this), you can specify elements to be measured to include both borders and padding in the calculation. To do this, you can either specify it for each individual element (if you don't want it to happen with all elements), or you can simply use a universal selector to declare it, like this:
* {
box-sizing: border-box;
}
Adding that to the top of your stylesheet should fix your problem! :)
Michal Broniewicz
6,681 PointsMichal Broniewicz
6,681 PointsI totally forgot about it! Thanks!!
Michael Kalmykov
8,919 PointsMichael Kalmykov
8,919 PointsThis helped me too!
Thanks!
Martins Rokis
6,995 PointsMartins Rokis
6,995 Pointsi got same problem, but adding
/* Page Styles ================================ */ *{ list-style:none; box-sizing: border-box; }
body { font: normal 1.1em/1.5 sans-serif; color: #222; background-color: #edeff0; } .main-wrapper{ width:90%; margin:auto;
}
/* Layout Element Colors ================================ */
.main-header { background-color: #384047; } .main-logo { background-color: #5fcf80; } .main-nav li { background-color: #3f8abf; } .primary-content { background-color: #caebf6; } .secondary-content { background-color: #bfe3d0; } .main-footer { background-color: #b7c0c7; }
/* Header, Banner and Footer Layout ================================ */
.main-header{ padding:20px; display:table; width:100%; min-width:150px; } .main-logo, .main-nav, .main-nav li{ display:inline-block; } .main-logo, .main-nav li{
border-radius:5px;
} .main-logo{
width:120px;
} .main-nav li{
margin-left: 10px;
} .main-nav{ padding-left:50px; } .main-logo a, .main-nav a { color: white; text-decoration: none; display:block; text-align:center; padding:10px 20px; } .main-nav{ margin:0; padding:0;
} .main-logo, .main-nav{ display:table-cell; vertical-align:middle; } /Column Layout/ .col{ display:inline-block; padding:20px; margin-right:-5px; } .primary-content{ width:60%; } .secondary-content{ width:40%; }
/Media Queries/ @media (max-width:768px){ .main-logo, .main-nav, .main-nav li{ display:block; width:initial; margin:initial;
}