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
Hello @Sachin Khosla
Im working atm on my webpage offline and i was searcing for a simple buton like this on google
after a quick search i cam to this website where it show the button Suggest a post, i copy the code on to my index.html and give it a try, on my website it work fine very good html code and css but my question is why o cant use the same button twice on the same page, i did some modification to the code and i put a facebook icon and a twitter icon copy the code twice and put it in my index html, but the problem it is not showing twice the icon it show just the first one facebook i would like to have them both one on top of each other :0 could you please help me here and thoild me where im doing wrong and why it show just one icon
Thank you in advance you can mail me at mrzoomzoom2010@gmail.com
Hey there,
For having a another sticky button like this, you will need to assign it a different ID and then different CSS.
For instance, the CSS ID of the above button is #suggestPost , but for the second button (facebook in your case), you will have to give another unique and different attributes to top and left selectors, such it doesn’t hide behind the first one.
Cheers !!
Sachin Khosla
Sorry i didn’t see the replay button here so i opened a new comment
and i was trying to put “a herf=link” and it not show
Hello can you please answer my question
@Sachin Khosla
Cool Thank you for the quick respond and the help you provide
hehe but i have another issue i put the link facebook.com where t say
but seems to is not working it give me a non working page
This would be my last question if you could please help me with it
Thank you Sachin Khosla.
Hello there,
Past mabe 5days and i still w8 -ing for a help here with mi link to the side button i was tring all the things posibile and seem to it dosent work at all.
So my question is: How to put another link to my Sugested post so in order to get from something from the web server, to go to another page out side of the website.
Thank you in Advance.
Thanks my friend. I used your code successfully in my website
Hello, I seem to have issues with Firefox — the entire website seems to be shifted left in firefox, yet in IE, it’s correctly centered. Is there any specifics where the div or any tags go when I embed into the php page?
I removed
div#suggestPost:hover
{
background-position:-41px 0px;
}
and then it worked on forefox. you don’t get the nice rollover effect but it works for now.
Hi Sachin,
How do I add the code to a SharePoint 2010 site?
Just like you add any other HTML code
Iam Allready created my hml page, iam insert your script in left side on my html page, and iam preview my html page showen my html page in left side, what is this my page showen in left side, please reply me.
Make sure you have closed divs properly.
Thanks, Script Is Worked
Great little bit of code. Thanks so much
great clean code …tx…