Trouble Lining Columns for Portfolio Project

Trouble Lining Columns for Portfolio Project


My columns won’t line up not sure what I’m doing wrong. Not sure if by adding an image to the first causes my second column to line up way down and not next to it. Any help would be appreciated.

`My HTML:`
          <body class = "bgcolor">
        <div class = "header">
          <h1>Sathish's Portfolio</h1>    
          <button type = "button" class = " buttons buttonshov">Projects</button>
          <button type = "button" class = "buttons buttonshov">About Me</button>
          <button type = "button" class = "buttons buttonshov">Contact</button> 
          <h2 class = "center">Projects</h2>
          <h3 class = "center">----------$----------</h3> 
        <div class = "container">
        <div class =  "row">
          <div class = "col-md-4">
            <h4 class = "projectone">Project 1 </h4>
            <div  class = "projpic">
            <img class = "center" src = "" alt = "google logo">
          <div class = "col-md-4 center">
            <h4 class = "projecttwo">Project 2</h4>
            <img src = "" alt = "google logo">



  background-color: royalblue;  

  padding: 10px 24px;

  box-shadow: 0 12px 16px 0 rgba(0,0,0,0.24), 0 17px 50px 0 rgba(0,0,0,0.19);


  width: 250px;



why do you have </div> after your </body> tag?
I know this kind of mistake can mess everything up!


That last </div> tag closes the beginning <div> tag, is it supposed to be <body><div></div></body> rather than what I have?


Not much further than you but boiler plate html document looks like this :slight_smile:
<!DOCTYPE html>
here your links + meta

Your code here

Do you have a pen? (I mean on Codepen :slight_smile:)


Yes here’s the link to my pen: if you can’t view it let me know. Thanks for your help!


sorry I copied your code, look here.

You’ll see I removed the class="bgcolor" (it it’s necessary I think it’s better not to apply it to BODY).

I’ve offset your first column by 2 so that the content is centered. You only have 2 images, right?


Yes only two images. This is great thanks! Pretty much what I wanted. Can you explain what “offset-2” class does and how it and removing “bgcolor” fixed things? Only because bgcolor defined the background color and font color so I didn’t think it would affect alignment.

I also didn’t know you could add body to CSS and it would do it for you so thanks for that too!


I don’t think removing the class from the body changed anything but I just found it strange. You can however add that class to other elements !

To understand the grid, remember that no matter what, you have 12 units in a row.

You can use those units the way you want, so by columns of 4 units (then you’ll have 3 columns), or by columns of 6 units (so 2 columns) or for example one column of 3, one col of 2, etc…

In this case you have only two col of 4 units.

12 - (2 x 4) = 4 units.

So you have 4 units to distribute around your columns to make them centered etc.

So you tell your first column (the left side) to “start” 2 units later.

Hence col-md-4 col-md-offset-2


then look at this here. Might be a bit much but anyway.

Also see the wiki on CSS here on the forums.

any html tag can be a CSS selector. It’s just less specific than a class selector, but it’s not the a bad thing. Juggling with dozens of classes and ids is not ideal (for maintenance among other things).

So you could target your text with h1{color:white} for example.


Thanks for your help! I also noticed I didn’t have for my CSS tab. Whoops


typical ! you’ll also forget your jQuery when you need it :wink: everybody does !


I cleaned up your code.
You need to use triple backticks to post code to the forum.
See this post for details.