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 trialHayden Bradfield
1,797 PointsHow come my column to the right is shifted down one line?
Here is a screenshot of what I am talking about: http://i.imgur.com/pgt618X.png
When I added the two column layout, it seems my right column is shifted down by one line. Meaning, the top of the box is uneven with the left side.
My code:
body { background-color:white; margin: 0% 0% }
section { background-color:white; margin-top:0% 0%; padding-right:15px; height:100%; } header { background-color:#465E84; }
header h1 { margin: 0% 0%; text-align:center; padding-top:4px; padding-bottom:3px; font-family: 'Bungee Inline', cursive; }
header h1 small { font-family: 'Gloria Hallelujah', cursive; }
header a { text-decoration:none; color:white; }
h2 { margin: 0% 0%; padding-top:0.5em; }
p { word-wrap:break-word; padding-bottom:0.5em; display:block; }
nav { background-color:#89cff0; margin: 0% 0%; text-align:center; }
nav ul { margin: 0% 0%; padding-top:0.5em; padding-bottom:0.5em; list-style:none; padding-left:0px; }
nav ul li { display:inline; text-align:center; margin: 0% 0%; padding-left:4px; padding-right:4px; }
nav ul li a { text-align:center; margin: 0% 0%; text-decoration:none; color:#465E84; font-family: 'Fjalla One', sans-serif; }
nav ul li a:hover { color:white; }
p { margin: 0% 0%; }
foot {
margin: 0% 0%;
background-color:#465E84;
height:100%;
bottom:0;
position:relative;
text-align:center;
color:#89cff0;
}
wrapper {
min-height: calc(100vh - 18px);
}
/* ======= Media Query ========== */
@media (min-width:200px) {
section h2 {
padding-left:7px;
padding-right:7px;
font-size:18px;
}
p {
padding-left:7px;
padding-right:7px;
font-size:15px;
}
}
@media (min-width:780px) {
section h2 {
padding-left:20px;
padding-right:20px;
font-size:22px;
}
section p {
padding-left:20px;
padding-right:20px;
font-size:18px;
}
.col {
display:inline-block;
max-width:50%;
margin-right:-4px;
background-color:#999;
}
}
1 Answer
Mark Dekin
26,839 PointsThis is because your .col is given the display of inline-block. inline-block elements are aligned at their "baseline". You have two options here: simply need to also add the vertical-align: top to .col OR give them both a defined height of the same amount, the downfall there though is that too much text will overflow that defined height.
Hayden Bradfield
1,797 PointsHayden Bradfield
1,797 Pointsthe vertical-align:top worked best. Thank you!