Hey, I would like to create a tab/erollover effect using css on some links. The problem is I am not sure how to get the whole of my image displayed in the background of the link.
So for example if my image is 100px wide, but my text only 40px wide only 40px of my background are displayed. How can I solve this?
a {
display: block;
width: 100px;
}
That's all you need. Maybe text-align: center to make it look pretty too.
Your issue will be if people resize your link beyond the size of your background, so make sure it tiles well both horizontally and vertically (although if it's 40 px, it's most likely not going to happen.)
ok I have set up the following set of links with the following css code - however rather than displaying in a nice line they are stacked horizontally... how can I stop this and have them displayed vertically one next to the other?
I think you've got your directions mixed up. If you want them in a HORIZONTAL line, like this:
link.. link... link... link...
then you're going to have to use a colspan to be sure the cell goes all the way across. You might have to string the <a href="lxxxx">links one after the other. If you used an undordered list instead of links in a table cell, all you have to tell it is "display: inline".
What you're getting the links stacking VERTICALLY like this:
link
link
link
link
__________________
Web Goddess & Web Standards Evangelist :) - Tables Be Gone !!
EEWWWW!!! Don't USE Tables. Too Much code. It drastically changes your code to content ratio if you use divs, td, dd, ul, li. Try those instead. It helps you build a much cleaner site.