Clothesline Social Bookmarks – A CSS-only Social Bookmarking Tutorial

Today we will create a fancy social bookmarking solution which will not require any JavaScript – it is only CSS based. We will hang up some rotated social bookmark icons […]

Today we will create a fancy social bookmarking solution which will not require any JavaScript – it is only CSS based.

We will hang up some rotated social bookmark icons on a clothesline and put a cute Tweetie sitting on top of it. This will just be an example and, of course, you are encouraged to add the social bookmarks that you find relevant to your page. This solution is just a showcase and might be way too big for some tastes.

In this tutorial you will learn about

  1. absolute positioning of elements
  2. using background images
  3. using negative positioning values
  4. social bookmark links for static pages and for WordPress

Ok, let’s start with the markup.

1. The HTML

The Markup will consist of a div that contains the social bookmark icons as links. Each link will have a span inside which will be the clothes pin “holding” the icon. Additionally, the main div will contain a div for the clothesline itself:

<div class="cl_container">
	<div class="cl"></div>
	<a class="digg" href=" Social Bookmarking Tutorial"><span></span></a>
	<a class="tech" href=""><span></span></a>
	<a class="mixx" href=""><span></span></a>
	<a class="stumble" href=" Social Bookmarking Tutorial"><span></span></a>
	<a class="reddit" href=" Social Bookmarking Tutorial"><span></span></a>
	<a class="twitter" href=" Social Bookmarking Tutorial"></a>

The links are all specific for the according service and usually it is required to provide the URL and the title of the website. In this case, we provided static information. If you want to contact the services from you WordPress blog, you can add some PHP code to dynamically set the URL and title of the article that you are posting. For that, you will need to replace the URL and, if needed, the title with the PHP function that provides the URL and title of the article:

  • URL: <?php echo get_permalink() ?>
  • Title: <?php the_title(); ?>

You can use a service like iFeedReaders to create all the links for you.

2. The CSS

The main container will have relative positioning because we want to be able to use it somewhere on a webpage:

	background:transparent url(../images/cl.png) repeat-x 0% 40px;

The container will have a repeated background image which will be the clothesline. The horizontal position shall be 0 which means that it will be left and the vertical position will be 40px which means that the image will be 40px from the top.
Now, we will define the link elements and all their common properties:

.cl_container a{
.cl_container a:hover{

The width and height of the elements should be the size of the images that you are using. These ones are pretty big. The top position will be 32px since we want the icons to look like they are attached to the clothesline. Only for the cool browsers we say that the opacity is 0.8 initially and 1.0 when hovering. This will create a neat effect. (You might as well use this filter property for IE: filter:progid:DXImageTransform.Microsoft.Alpha(opacity=80), if you really really need to…)

The icons will have the following properties:

	background:transparent url(../images/digg_koi.png) no-repeat top left;
/* each around plus 168px*/{
	background:transparent url(../images/technorati_koi.png) no-repeat top left;
	background:transparent url(../images/mixx_koi.png) no-repeat top left;
	background:transparent url(../images/reddit_koi.png) no-repeat top left;
	background:transparent url(../images/stumble_koi.png) no-repeat top left;

And the pin (which is the span inside of the link elements) will have the following style:

.cl_container a span{
	background:transparent url(../images/pin.png) no-repeat top left;

We need to position the pin in the middle of the surrounding link element which is 130 pixels wide and so we set left to 55px. Since we positioned the clothesline image in the middle of the main container, we need to pull the pins “up”. We do that by giving a negative top value of -22px. Of course, we could have positioned the whole main container differently and avoid using this negative value now, but it shows how you can simply use negative values when it comes in handy. In other scenarios you can profit of negative margins and positioning because, instead of moving more elements around, you can adjust just one single element by giving it a negative positioning or margin.

And last, but not least, we add the style of cute Tweetie:

	background:transparent url(../images/twitter.png) no-repeat top left;

The Twitter bird needs to be pulled up in order to make it look like he sits on top of the rope. So, we say top:-85px.

And that’s it!

The resources for this tutorial can be found here:

Please get the icon sets there since I am not allowed to redistribute them like this (I cannot provide them in the downloadable zip file).

Happy new year and enojy!!!

Tagged with:

Manoela Ilic

Manoela is the main tinkerer at Codrops. With a background in coding and passion for all things design, she creates web experiments and keeps frontend professionals informed about the latest trends.

Stay in the loop: Get your dose of frontend twice a week

👾 Hey! Looking for the latest in frontend? Twice a week, we'll deliver the freshest frontend news, website inspo, cool code demos, videos and UI animations right to your inbox.

Zero fluff, all quality, to make your Mondays and Thursdays more creative!

Feedback 7

Comments are closed.
  1. Pingback: Clothesline Social Bookmarks – A CSS-only Social Bookmarking … | Kerja Keras Adalah Energi Kita

  2. Pingback: Clothesline Social Bookmarks – A CSS-only Social Bookmarking … | Coder Online

  3. What a wonderful blog! Please continue this great work I will be sure to check back regularly…

  4. Pingback: Varal de Social Bookmarks apenas com CSS - Top of your Mind

  5. Thanks, this is awesome.. been searching for hours for something like this, bookmarked your site also, excellent content, im just learning jquery so you’ll have a hard time getting me off your site now lol.

    Thanks again