Regular visitors of Digimantra might have noticed that recently we introduced “Suggest a post” button on the left side of the webpage. Some one anonymously sent a request to write a post on how to create these sort of fixed buttons on the website. This is very simple, yet look very nice tagged along the site.
So let us start by creating those rounded corner images. You can read this post on how to create gradient buttons ,so as to make your own in the photoshop.If you do not want to create your own image, you can use the one I created.

Did you notice we have this image with similar text but their background color is different. This is where we are going to use these colors for the mouseover effect. I have also given a 1px difference in the text position so as to give a little shift when mouse hovers over the button. You might have noticed that.
Now the HTML and CSS to achieve this is as follows :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <style type="text/css"> *{margin:0px;padding:0px;} #suggestPost { background:transparent url(suggest-post.png) no-repeat scroll 0px 0px; height:170px; left:0; position:fixed; top:150px; width:40px; } div#suggestPost:hover { background-position:-41px 0px; } #suggestPost a { display:block; height:170px; width:40px; } </style> </head> <body> <div id="suggestPost"><a href="#" ></a></div> </body> </html>
Some facts about the above lines of code
- You can position this by changing the value of top:150px. This changes the position of the button from top of the browser.
- The CSS property position:fixed; make this button sticky no matter even if the user scrolls it up or down.
- The hover effect is the result of the pseudo CSS property :hover which we have used in div#suggestPost:hover and we have changed the background-position of the image, which gives the effect.
- Do not forget to add a valid DOCTYPE in the HTML file, otherwise Internet Explorer is clever enough to behave erroneous.
Hope you like this post.
Stay Digified!!
Sachin Khosla.





“Internet Explorer is clever enough to behave erroneous.” LOLZ!!
Thats way too optimistic!! I hate IE!!
Thanks for this one!!
Thanks very much! This is great! I’m able to use the code in my site
that looks great.
thanks
I copied the enitire code as an HTML, with the image specified in the same folder. Not working. Anything went wrong from my side.
can you share the link or something.. which browser are you trying. May be a browser issue !!
Thanks for your quick response. I didn’t uploaded it to Interenet. Just created a new HTML (.htm file) file copied entire content of code to it. Also saved the picture file to that folder. Tried in IE 8 & Firefox 3.6.2 latest. Iam using Windows 7. Just a white screen only. No side link appearing.
probably you din paste the code propery, anyways just see the demo here and copy its source, that should work for you.
http://www.digimantra.com/resources/side_button.html
Thanks a lot for your patience with me. I worked the Html file directly double clicking it. Anyway the example is working fine. Thanks once more
@Rafeeque Anytime dude