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

PHP

How can I right-align php code?

Hi,

I would like to add social media icons in the header with right alignment. I have managed to add them using a plugin and php code but I can’t align them to the right. Can you have a look please and help me?

This is the code I have added:

<?php DISPLAY_ACURAX_ICONS();?>

website: #########

Thank you very much for your help! Have a nice day.

3 Answers

Hello,

Based from your code, you can add an element rue using the id of the div and set the text alignment to right with !important.

eg

#short_code_si_icon { text-align: right !important; }

Hi!

I've noticed that your social links contains the following code:

<div id="short_code_si_icon" style="text-align:center;"><a href="https://www.facebook.com/coho.gr?ref=hl" target="_blank" title="Visit Us On Facebook"><img src="http://www.coho.gr/blog/wp-content/plugins/floating-social-media-icon/images/themes/1/facebook.png" style="border:0px;" alt="Visit Us On Facebook"></a><a href="http://www.linkedin.com/company/3030321" target="_blank" title="Visit Us On Linkedin"><img src="http://www.coho.gr/blog/wp-content/plugins/floating-social-media-icon/images/themes/1/linkedin.png" style="border:0px;" alt="Visit Us On Linkedin"></a><a href="http://www.twitter.com/coho coworking home" target="_blank" title="Visit Us On Twitter"><img src="http://www.coho.gr/blog/wp-content/plugins/floating-social-media-icon/images/themes/1/twitter.png" style="border:0px;" alt="Visit Us On Twitter"></a><a href="https://plus.google.com/+CohoGr/posts" target="_blank" title="Visit Us On Google Plus"><img src="http://www.coho.gr/blog/wp-content/plugins/floating-social-media-icon/images/themes/1/googleplus.png" style="border:0px;" alt="Visit Us On Google Plus"></a><a href="http://www.youtube.com/user/coho4coworking" target="_blank" title="Visit Us On Youtube"><img src="http://www.coho.gr/blog/wp-content/plugins/floating-social-media-icon/images/themes/1/youtube.png" style="border:0px;" alt="Visit Us On Youtube"></a></div>

I think, the inline style style="text-align:center;" is why you are not able to align this links to right.

Thank you very much for your quick response! With your help and with extensive research I found the solution.

I had to add this code to the style.css file

#short_code_si_icon { text-align: right !important; padding-right: 190px; }

Thank you very much.