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

Killeon Patterson
Killeon Patterson
18,528 Points

I'm attempting to line classes 'keeper, keeper-1' horizontally next to each other. How can I do that?

<!DOCTYPE html> <html> <head> <meta charset='UTF-8'> <title>Sat9</title> <link rel='stylesheet' href='css/normalize.css'> <link rel='stylesheet' href='css/style.css'> </head>

<body>

<div class='wrap'> <header class='main-header'> <div class='container'> <h1 class='name'><a href='#'> T.H.W</a></h1> <ul class='main-nav'> <li><a href='#'>Lifestyle</a></li> <li><a href='#'>Business</a></li>

</ul> </div>

</header>

<div class='banner'>
        <img class="logo" src='img/main.PNG' alt="City">
    <h1 class="headline">The Hair Wars</h1>
    <span class="tagline">Women and Beauty</span>

</div>

<div class='masterkeep'>

<div class='keeper col'> <figure>

  <img class='icon-logo' src='img/icon-logo.JPG' alt='logo'>
  <img class='feat-img' src='img/hair.PNG' alt='zero'>

  <figcaption>
   Once upon a time
  </figcaption>
</figure>

</div>

<div class='keeper-1 col'>
<figure>

  <img class='icon-logo-1' src='img/icon-logo.JPG' alt='logo'>
  <img class='feat-img-1' src='img/hair.PNG' alt='zero'>

  <figcaption>
   Once upon a time
  </figcaption>
</figure>

</div>

</div>

</div>

<footer class='main-footer'> </footer> </body>

</html>

/*******CSS**********/

  • { box-sizing: border-box; }

body { line-height: 1.6; color: #3a3a3a; }

a { text-decoration: none; }

img { max-width: 100%;

}

figure { margin: 0; line-height: 0; position: relative; }

figcaption { font-size: .9em; line-height: 1.5; font-weight: bold; text-align: center; color: black; padding: 1em;
background-color: white; opacity: .65;

position: absolute;
bottom: 3em;
width: 15%;

}

.main-header { text-align: center;

}

.banner { text-align: center; position: relative; }

.name { font-size: 1.45em; color: #ff1d8e;

}

.name, .main-nav, .main-nav li {

background: #fff; display: inline-block;

}

.main-nav { padding-left: 1em;

}

.main-nav a { font-size: .95em; color: #ffc3e1; text-transform: uppercase; }

.main-nav a:hover { color: #ff87c3; }

.container { padding-left: 1em; padding-right: 1em;

}

.main-header { background-color: #fff; height: 3.5em; }

.headline { color: black; font-size: 4em; background-color: white; width: 80%;

position: absolute; top: 1em; left: 2.2em; }

.tagline { color: white; font-size: 2.5em;

position: absolute; top: 5.3em; left: 13em; }

.main-footer { background-color: #ff1d8e; height: 1.5em; }

.keeper, .keeper-1 { padding-left: 5em; padding-top: 2em; }

.icon-logo, .icon-logo-1 { width: 2%; position: absolute; top: 1em; left: 1em; border-radius: 100%;

}

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

@media (min-width: 769px) {

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

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

}

@media (min-width: 1025px) {

.name a { color: #ff1d8e;

}

.col { display: inline-block; margin-right: -4px;

}

.feat-img, .feat-img-1 { max-width: 15%;

}

}

Killeon Patterson
Killeon Patterson
18,528 Points

I'm not sure why the posting is separating the code like that.

2 Answers

Hello,

your code has not come through clearly but have you tried in the css, setting the body position to relative and then each div to absolute, then placing them on the page where you want them?

Another option is using flexbox.

Guil Hernandez
STAFF
Guil Hernandez
Treehouse Teacher

Hey Killeon Patterson,

As Tracy Excell mentioned, you could give the masterkeep div a display: flex and its children should line up horizontally. Also, make sure you give each img a width or max-width of 100%.

Hope this helps. :)