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

How do I get my 'back to top' button and my social icon away from each other?

I cant get my social icons and my back to top button off of the same line. I'm trying to figure out and move things around, but it doesnt move.

CODE:

CSS:

footer { font-size: 0.75em; text-align: center; clear: both; padding-top: 50px; color: #ccc; }

.social-icon { width: 20px; height: 20px; margin: 0 25px; } }

HTML:

<footer class="main-footer"> <a href="http://twitter.com/A_tone"><img src="img/twitter-wrap.png" alt="Twitter Logo" class="social-icon"></a> <a href="http://www.facebook.com/anthony.conti.391"><img src="img/facebook-wrap.png" alt="Facebook Logo" class="social-icon"></a> <a href="#top">Back to top ยป</a>

1 Answer

#back-to-top {
  display:block; /* to put element on its own line */
  text-align:right; /* for some reason i think your back to top button would be on the right side */
}

EDIT: Oops, I thought your back to top link had an ID of top. I changed it to "#back-to-top" but you'd have to add that ID to the element in your html.

So I need to add a back to top ID in my HTML after entering this in my CSS?

Correct. So your new html would be:

<a href="http://twitter.com/A_tone"><img src="img/twitter-wrap.png" alt="Twitter Logo" class="social-icon"></a>
<a href="http://www.facebook.com/anthony.conti.391"><img src="img/facebook-wrap.png" alt="Facebook Logo" class="social-icon"></a>
<a id="back-to-top" href="#top">Back to top &raquo;</a>

If your back-to-top link is a button and this approach doesn't work for you, you could adjust your html with doing anything to your css. Just wrap the back-to-top link in div tags to get the display:block effect without causing the link to be 100% of the screen width:

<a href="http://twitter.com/A_tone"><img src="img/twitter-wrap.png" alt="Twitter Logo" class="social-icon"></a>
<a href="http://www.facebook.com/anthony.conti.391"><img src="img/facebook-wrap.png" alt="Facebook Logo" class="social-icon"></a>
<div>
  <a href="#top">Back to top &raquo;</a>
</div>

I actually think this is a better approach.

Thank you I liked the div approach better too, and it worked. I appreciate the help!