Web_Designer_Issue_262_2017
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Tutorials<br />
Code social media buttons for WordPress<br />
8. Default menu display<br />
Your new menu should now appear in your layout in the<br />
area you selected. It will currently be in the style of the<br />
other menus, with text and not icons. The generated<br />
markup, depending on your theme, will look similar to this<br />
(additional IDs and classes added by WordPress have<br />
been omitted for clarity).<br />
<br />
Facebook<br />
Twitter<br />
[...]<br />
<br />
9. Start styling<br />
You can now add CSS to your theme files, or in<br />
WordPress 4.7 and above, you can add CSS via the<br />
Additional CSS theme options. Go to<br />
Appearance>Customise in the Admin panel and open the<br />
Additional CSS tab. CSS saved here will apply only to this<br />
theme, and will not edit your theme files.<br />
FontAwesome is<br />
an icon font<br />
They scale to any size, big or small! They are great<br />
for all screen types: desktop and mobile. They’re<br />
also tiny in file size so they load faster than<br />
images and can be recoloured with CSS!<br />
10. Align buttons side by side<br />
Start by adding styles for all the buttons as a basis for<br />
customising each individual link. This code will start by<br />
aligning your buttons side by side. Depending on your<br />
theme you may need to make adjustments.<br />
#menu-social-media-menu .social-button {<br />
display: inline-block;<br />
box-sizing: border-box;<br />
padding: 0;<br />
border: 0;<br />
}<br />
11. Turn text into button shapes<br />
Add block and background to the anchor links with width<br />
and height settings to make the base shape. Use a tall line<br />
height and hide the overflow to hide the text out of the<br />
viewport while still making it available to screen-readers.<br />
Add a margin to put some space between buttons.<br />
#menu-social-media-menu .social-button > a {<br />
display: block;<br />
background: #555;<br />
height: 30px;<br />
width: 30px;<br />
overflow: hidden;<br />
line-height: 200px;<br />
margin: 0px 3px;<br />
position: relative;<br />
}<br />
12. Add some style<br />
Give your buttons some panache! Set the border<br />
radius to 100% to make circles. Transition and transform<br />
can give your hover states a bit of a zoom and<br />
background colour change. This continues on from the<br />
last step’s additions.<br />
#menu-social-media-menu .social-button > a {<br />
[...]<br />
transition: all 0.2s;<br />
border-radius: 100%;<br />
}<br />
#menu-social-media-menu .social-button ><br />
a:hover {<br />
transform: scale(1.2);<br />
background: #ccc;<br />
}<br />
13. Add icon placeholder<br />
Now create the placeholder for the icon using the :after<br />
pseudo class. This will create a fake element using CSS<br />
that overlays your buttons, similarly to a div that we can<br />
style and add the icon to.<br />
#menu-social-media-menu .social-button ><br />
a:before {<br />
content: “\f00d”;<br />
font-family: “FontAwesome”;<br />
font-size: 14px;<br />
transform: rotate(0.001deg); /* IE Fix */<br />
color: #000;<br />
position: absolute;<br />
width: 30px;<br />
line-height: 30px;<br />
text-align: center;<br />
}<br />
Top left<br />
The list of FontAwesome icons is available at<br />
fontawesome.io/icons. There are many icon types<br />
available, not just social media logos<br />
Top right<br />
Use the search function to refine the view to a<br />
specific icon or scroll down to Brand Icons to see<br />
all site brand logos<br />
Right<br />
Click the icon to expand the full view. The unicode code<br />
that you need for CSS is in the grey bar just under the<br />
different sizes<br />
62