Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

HTML

martin wong
martin wong
4,799 Points

In mobile-view, 2 of my images above are lines up while the bottom 2 are out of position?

/****************************
General
*****************************/
body {
  color:#010;
  font-family: 'oswald', monospace;
  margin:0;
  padding:0;

}
#wrapper {
  margin:0 auto;
  padding:5px;
  max-width:940px;
}
img {
  max-width:100%;
}
a {
  text-decoration:none;
}

/****************************
LOGO/HEADING
****************************/
header {
  float: left; 
  margin:0 0 30px 0;
  padding:0px;
  width:100%;

}
#logo {
  text-decoration:none;
}
h1 {
  font-size:2em;
  font-weight:normal;
  color:#fff;
  text-align:center;
  background-color:#404040;
  margin:0px;
  padding:5px;
}
/*************
NAV
*************/
nav {
  margin:0px;
  padding:10px;
  line-height: 1.1em;
  padding-bottom:0px;
  text-align:center; 
  background:#d0d0d0;
}
nav ul {
  text-align:center;
  list-style:none;
  padding:0;
  margin:0 10px;
}
nav li{
  display:inline-block;
}
nav a {
  margin:15px;
  padding:18px;
}

nav a, nav a:visited {
  color:#FFF;
}
nav a.selected, nav a:hover {
  color:#131c1f;
}
/***************************
Imaging
***************************/
#gallery {
  margin:0;
  padding:0;
  list-style:none;
}
#gallery li {
  float:left;
  width:45%;
  margin:2.5%;
  background-color:#7f7f8f;
  color:#fff;

}
#gallery li a p {
  margin:0;
  padding:10px;
  color:#fff;
  font-size: 0.8em;
}
#gallery p:hover {
  color:#131c1f;
}


footer {
  clear:both;
  text-align:right;
  background:#404040;
  padding-right:15%;
}


/***************
Aboutme.html
****************/
img.photo {
  display:block;
  max-width:200px;
  border-radius:15%;
  margin:0 auto 20px;
}
h3 {
  font-family: 'oswald', monospace;
  font-weight:200;
  color:#000;
  font-size:1.5em;
  margin:0 0 0.5em 0;
}

.contact-info{
  list-style:none;
  font-size:1em;
  margin:0;
  padding:0;
}
.contact-info a{
  display:block;
  margin:0 0 0 5px;
  padding:0 0 0 30px;
  background-size:20px 20px;
  min-height:20px;
  background-repeat:no-repeat;
}
.contact-info li.phone a{
  background-image: url('../img/phone.png');
}
.contact-info li.e-mail a{
  background-image: url('../img/mail.png');
}


    /****FINISH OFF CONTACT INFO*****/
<!DOCTYPE html>
<html lang="en">

<!--Title-->
  <head>
  <meta charset = "utf-8">
  <title>Project of Martin Wong | HTML, CSS and Javascript</title>
  <link href="css/normalize.css" rel="stylesheet">
  <link href="https://fonts.googleapis.com/css?family=Oswald|Roboto+Condensed" rel="stylesheet">
  <link href="css/main.css" rel="stylesheet">
</head>

<!--Content-->
<body>
  <header>
    <a href="index.html" id="logo">
      <h1>I AM MARTIN WONG|Learner</h1>
    </a>
    <nav>
      <ul>
        <li><a href="index.html" class="selected">Portfolio</a></li>
        <li><a href="aboutme.html">About me</a></li>
        <li><a href="contact.html">Contact</a></li>
      </ul>  
    </nav>
  </header>


  <div id="wrapper">
  <section>
    <ul id="gallery">
      <li>
        <a href="img/hongkong1.JPG">
        <img src="img/hongkong1.JPG" alt="">
        <p>Experimentation with monochrome</p>
        </a>
      </li>
      <li>
        <a href="img/hongkong2.JPG">
        <img src="img/hongkong2.JPG" alt="Tai po">
        <p>Tai Po Market</p>
        </a>
      </li>
        <li>
          <a href="img/singapore1.JPG">
            <img src="img/singapore1.JPG" alt="Nearby Chinatown">
            <p>Somewhere in Chinatown, Singapore</p>
          </a>
        </li>
        <li>
          <a href="img/cardiffbay.jpg">
            <img src="img/cardiffbay.jpg" alt="cardiffbay">
            <p>Police present at Wales Millenium Centre in wake of terroist attacks that occured in London </p>
          </a>
        </li>
      </ul>
    </section>
  </div>

<footer>&copy; Martin Wong 2017</footer>
</body>

</html

So when i resize my browser to get the mobile view, my 2 images above are in line but the 2 below are out of position. I dont know what causing this, i have quite a bit of text in my 3rd image(bottom-left) which take up 5 lines.

first image takes up 2 lines, second 1, third 5 and last image 1line. any ideas?

Thanks

1 Answer

Hi Martin,

The problem is the container height. You can set a min height on lower screen size, use flexbox, or some JS to help solve this rather easy. Flexbox is most likely the easiest way and Treehouse has some good courses on it and it works great for doing stuff like this.