0845 205 0292

Request A Free Website Analysis

Close

CSS Pop-Up Icons

December 6th, 2010 by

There are any number of JavaScript and jQuery plugins that do this effect, but what happens if a potential client does not have JavaScript enabled? Do you not show the content, or just not show the animation? With CSS, you can have your cake, and eat it too.

CSS Share Bar

Hovering Share Bar

As an example, we’re going to work on a social media share bar. You’ve undoubtedly seen them on many sites (heck, we’ve even got them on this site). They look snazzy and can drive your social ranking up. But turn off JavaScript and most of the time you’re left with a boring text link that looks out of place on your webpage.

So here is our CSS only share bar that ‘pops’.

First of all, our mark-up:

<div class=”sharebar”>
<a rel=”nofollow” href=”http://www.delicious.com/save”><img src=”/images/delicious.png” alt=”Delicious” title=”Bookmark on Delicious”></a>
<a rel=”nofollow” href=”http://digg.com/submit”><img src=”/images/digg.png” alt=”Digg” title=”Bookmark on Digg”></a>
<a rel=”nofollow” href=”http://www.facebook.com/share.php”><img src=”/images/facebook.png” alt=”Facebook” title=”Bookmark on Facebook”></a>
<a rel=”nofollow” href=”http://reddit.com/submit”><img src=”/images/reddit.png” alt=”Reddit” title=”Bookmark on Reddit”></a>
<a rel=”nofollow” href=”http://twitter.com/share”><img src=”/images/twitter.png” alt=”Twitter” title=”Bookmark on Twitter”></a>
</div>

and our CSS:

.sharebar a img
{
width:20px;
}
.sharebar a:hover
{
position:absolute;
}
.sharebar a:hover img
{
width:34px;
position:relative;
left:-6px;
}
.sharebar a:hover + a img
{
padding-left:25px;
}

So what does all this mean?
By default, we want our images to be smallish. So we set the width at about a third of the original size at 20 pixels.

CSS Share Bar

Small Share Bar Icons

Now comes the interesting part. When we hover over the link we want it to get larger. The problem with this is that it shifts the rest of the icons after it, and this can mess up the layout of your page (see image 3). By positioning the parent anchor as absolute we can have it, and our image, pop out of the mark-up. This will shift the following icons to the left, to fill in the space left by our ‘missing’ icon.

Large Share Bar Icon (image 3)

Large Share Bar Icon (image 3)

Shifted Share Bar Icons

Shifted Share Bar Icons

Using the css sibling select (+) we can select the image of the next anchor and give it some padding to push it back to the right.

Share Bar Icons Stay In Place

Share Bar Icons Stay In Place

Finally, just to make it appear the hovering image has scaled from it’s centre, and not just pushed out to the side, we set it’s position as relative and shift it left by a few pixels.

Share Bar Icons Stay In Place

'Acitve' Icon Scales From Centre

This is valid (x)html. Valid CSS. And most importantly, it works with JavaScript turned off which means that your web page is still accessible, and you still have your cool effect to wow your client base.

This entry was posted on Monday, December 6th, 2010 at 11:55 am . RSS GlobeYou can follow any responses to this entry through the RSS feed.

Link to us

If you want to link to this blog, copy and paste the following HTML code to your website.

Navigation

Blog Categories

Free SEO Analysis & Proposal

From The Blogread news

Latest Newsread news

  • MAY 15
    With over 10million users in the UK and a somewhat eventful 12 months behind it, Twitter have finally agreed to work more closely with Government and policymakers in the UK. The Social Network currently has over 140million user...
  • MAY 14
    Following the recent Panda and Penguin updates recently, the content written for websites has become more of a focus; being more relevant and of better quality. Google is penalising content which is full of keywords to the point o...

Clients Say...

"We've long been considering an SEO campaign and have researched the benefits that it could potentially bring to our web presence," commented 3663 Catering Equipment's Managing Director Paul Knight. "The team at Click Consult put together a very attractive package and we're pleased to be able to enter into a sound business partnership with them. We're looking forward to seeing the results they can provide for the 3663 Catering Equipment website moving forward."

3663

Managing Director - 3663 Catering

"We have been working with Click Consult for over a year now. We are delighted with the increase in unique visitors to our site and they have far exceeded our conversion KPI metrics for customer database registrations. We rank in the top 3 for all keywords that we asked Click Consult to optimize for us. This agency know how to produce results."

hills pets

Managing Director - Liverpool One

"Whilst we have a long term keyword strategy, Click Consult have a good appreciation of our business and have a flexible approach to implementing short term keyword strategies to coincide with the peaks of the retail calendar. I receive a monthly performance report from Click Consult detailing the relevant data I require but in addition, I can review the work being undertaken at any time by logging in to their bespoke reporting system."

hills pets

CRM Manager - Liverpool One

"Hills has been looking for an agency that is able to quickly deliver in the search marketing area and catapult EMEA websites ahead of the competition. Taking SEO Consult for this project turned out to be a smart choice. Not only have they managed to significantly increase search engine traffic to our websites, but they also come with innovative ideas that can be turned to reality. I can simply say they deliver. And it's always a pleasure talking to them."

hills pets

Managing Director - Hills Pets