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

Ryan Bevilacqua
Ryan Bevilacqua
7,716 Points

Floats, Displays, and Clears, Oh My.

Okay Team TreeHouse,

My name is Ryan and I'm a noob.

I have been working at this code for 2 days and I need professional help. All I would like to do is create 2 columns for my contact page and have the columns centered on each other. I would also like to align my icons with their elements. Please help and put me out of this misery.

Sincerely,

Ryan

p.s. There is something going on with this forms where it combines all my code into one paragraph. I had to put an return in after each element.

<section class = "clearfix">

                <h2>CONTACT</h2>

                <div class="contact">

                    <ul id="cL">

                        <li>

                        <img id="contactImage" src="http://www.janicewagner.com/murals/ice-cream-parlor.gif">

                        </li>

                        <li>
                        <p>222 Delicious Ave, West Palm Beach FL 33407</p>

                        </li>

                        <li id="contactPhone">

                            <a href= 561-222-3344><p>561.222.3344</p>

                            <img id="phone" src="https://cdn4.iconfinder.com/data/icons/social-icons-6/40/phone-512.png">

                            </a>

                        </li>

                        <li id="contactEmail">

                            <a href="Creamoftheice@gmail.com">

<p>Creamoftheice@gmail.com</p>

                            <img id="mail" src="https://cdn4.iconfinder.com/data/icons/social-icons-6/40/mail-512.png">

                            </a>

                        </li>

                    </ul>

                </div>



            </section>
--------------------------CSS-------------------------
/*--------------------CONTACT-----------------*/

#contactImage{


    border-radius: 150%;

    border: solid 5px white;

    box-shadow: 0px 0px 10px 1px #E0E0E0;

    width: 70%;


}

#cL li{

    float: left;

    vertical-align: middle;

}

#contactPhone{

    display: inline-block;

}

#contactEmail{

    display: inline-block;

}


#phone,

#mail{

    width: 20px;

}


.clearfix::after{

    content: " ";

    display: table;

    clear: both;

}

2 Answers

Steven Parker
Steven Parker
229,732 Points

:point_right: Instead of floats, what about just wrapping each column in a inline-block div?

It might look something like this:

code.html
<section class="clearfix">
  <h2>CONTACT</h2>
  <div class="contact">
    <div class="column">
      <img id="contactImage" src="http://www.janicewagner.com/murals/ice-cream-parlor.gif">
    </div>
    <div class="column">
      <ul id="cL">
        <li>
          <img id="globe" src="https://cdn4.iconfinder.com/data/icons/social-icons-6/40/dribbble-128.png">
          222 Delicious Ave, West Palm Beach FL 33407
        </li>
        <li id="contactPhone">
          <img id="phone" src="https://cdn4.iconfinder.com/data/icons/social-icons-6/40/phone-512.png">
          <a href="phone:561-222-3344">
            561.222.3344
          </a>
        </li>
        <li id="contactEmail">
          <img id="mail" src="https://cdn4.iconfinder.com/data/icons/social-icons-6/40/mail-512.png">
          <a href="mailto:Creamoftheice@gmail.com">
            Creamoftheice@gmail.com
          </a>
        </li>
      </ul>
    </div>
  </div>
</section>
styles.css
/*--------------------CONTACT-----------------*/

#contactImage {
  border-radius: 150%;
  border: solid 5px white;
  box-shadow: 0px 0px 10px 1px #E0E0E0;
  width: 70%;
}

#cL li {
  list-style-type: none;
  margin-top: 8px;
}

#globe,
#phone,
#mail {
  width: 20px;
  vertical-align: middle;
}

.clearfix::after {
  content: "";
  display: table;
  clear: both;
}

.column {
  display: inline-block;
  vertical-align: middle;
}
Ryan Bevilacqua
Ryan Bevilacqua
7,716 Points

Hi Steve,

Thank you for taking the time to review my question. Everything you suggested worked well. The only thing I can't get is getting the @ next to the email. Any advice to help me finish this project?

Sincerely,

Ryan