• Some users have recently had their accounts hijacked. It seems that the now defunct EVGA forums might have compromised your password there and seems many are using the same PW here. We would suggest you UPDATE YOUR PASSWORD and TURN ON 2FA for your account here to further secure it. None of the compromised accounts had 2FA turned on.
    Once you have enabled 2FA, your account will be updated soon to show a badge, letting other members know that you use 2FA to protect your account. This should be beneficial for everyone that uses FSFT.

CSS Don't Underline Image

MorfiusX

2[H]4U
Joined
Feb 13, 2004
Messages
3,007
I have the following code:
Code:
<a href="(irrelevant)">
<img height="16" width="16" id="avatarsmall" src="(irrelevant)" />
 (Person's Name)</a>

For my CSS, I have:
Code:
a {
color:#EEEEEE;
font-weight:bold;
margin:0 10px;
text-decoration:none;
}
#avatarsmall {
border:1px solid #999999;
padding:1px;
position:relative;
top:-1px;
vertical-align:middle;
}

Basically I am trying to do some like Digg's My Profile link at the top of the page. When you hover over the link on my page, both the image and the text are underlined. On Digg's site, just the text is underlined. I've looked through the code on Digg, but I can't seem to get this working properly. I want both image and the text as part of the same link object so that hovering either will cause an underline to occur, but only underline the text. Help!

TIA
 
You want a rule that targets images inside of a link that removes their decorations.
 
if you're overriding the default for a (non hovered) link to not have an underline, you should explicitly define a:hover as well otherwise browsers are free to do whatever their default is. what ameoba is saying is do
a:hover img { text-decoration: none; }
i believe
 
Try this:
a:link,visited,hover,active {text-decoration:none;}

Digging (no pun intended) through the Digg CSS, this is what they are doing. When I do this, both the image and the text don't have the underline on hover. I think I just might created two links, one for the image, and one for the text, and style them separately. It's just annoying not being able to figure out how they did it.
 
if you just want images you could (I think, sorry it has been a long day)
a img:link,visited,hover,active {text-decoration:none;}
 
I figured it out, finally!

The parent container needs to have:
Code:
#parent-div {position:relative}
And the image needs to have:
Code:
#link-img {position:absolute;left:-13px}
All the other styling is arbitrary.

The CSS for the image needs to have absolute positioning. This removes the underline on hover. The parent container needs to have relative positioning so that when you apply a left/top/etc, it doesn't apply this based on the window.
 
I would have thought something like what pat1006 said would work where you say img within a has no text decoration

a img:link,visited,hover,active {text-decoration:none;}
 
I had already tried that, but I tried again and every other possible combination mentioned just to be sure. I wasn't looking at the parent container attributes in Firebug when looking at the code on Digg.

Here is the HTML on Digg:
Code:
<a id="section-profile" href="/users/morfiusx"><img height="16" width="16" alt="morfiusx" src="/users/MorfiusX/s.png"/> My Profile</a>
Here is the parent container CSS:
Code:
.side-header {
float:right;
margin:0;
min-height:33px;
padding:0 175px 0 10px;
position:relative;
}
And here is the CSS of the link:
Code:
.side-header a {
display:block;
float:left;
line-height:1;
margin:11px 0;
padding:5px 10px 4px;
word-spacing:-0.1em;
}
And finally the image:
Code:
.side-header img {
border:1px solid #A2C1DE;
left:-6px;
padding:1px;
position:absolute;
top:12px;
vertical-align:middle;
}
After sorting through all that, my above post are the items that affect the appearance we are talking about. Basically, in FF, IE7, and IE8, the IMG is going to inherit some of the styling of the parent A unless you give it "position:absolute;". It seems to me that the suggestions above should work, but in testing they do not.
 
Can you post the site where you were having the problem. I've built a lot of websites in my day and never had a problem like that...
 
Back
Top