1 of 2
1
RE : Image underline links & how to remove them?
Posted: 26 April 2008 06:42 AM   [ Ignore ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  6551
Joined  04-15-2006

Hiya,

Just wondering if someone could help me with something that I am pretty sure should be really really easy to do.

I am trying to make all my text links on a page not use the standard text-decoration: underline style by making it text-decoration: none instead and then on a:hover I am providing a border-bottom: 3px solid #15c100; declaration instead. This does work fine but if I now have an image that has a link surrounding it I get the green border underneath the image. I still want the image to be a link but don’t want the line to be there.

I tried adding in :

a img {
    border
-style: none;
    
text-decoration: none;
}

but it doesn’t seem to want to work. Can anyone see from the code below (very simple code!) where I am going wrong. I think I must be going mad as this should be really simple but I reckon that I have probably stared at it for way too long now and so I am just missing the obvious answer.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<
html xmlns="http://www.w3.org/1999/xhtml">
<
head>
<
meta http-equiv="content-type" content="text/html charset=utf-8" />
<
title></title>
<
style type="text/css">
<!--
html {
font
-size: 62.5%;
}

body {
    color
: #666666;
    
font-size: 1.2em;
    
font-family: Arial, "Lucida Grande", Verdana, sans-serif, Helvetica;
    
margin: 0;
    
padding: 0;
    
text-align: center;
}

#wrapper {
    
margin: 0 auto;
    
width: 950px;
    
text-align: left;
}
a img {
    border
-style: none;
    
text-decoration: none;
}

a {
    text
-decoration: none;
}

a
:hover {
    text
-decoration: none;
    
border-bottom: 3px solid #15c100;
}

-->
</
style>
</
head>
<
body>
<
div id="wrapper">
<
br /><br />
<
a href="#" title="Link"><img src="http://www.google.co.uk/intl/en_uk/images/logo.gif" alt="Image 1" /></a>
<
br />
<
a href="#" title="Title">Title</a>



</
div>
</
body>
</
html>

Any help on this would be greatly appreciated.

Best wishes,

Mark

 Signature 

Full List Of Plugins Here!! (16)
 
Retrieve Statuses
Maximum Posts Reached
Neat Link
Redirect
Fetch URI

Profile
 
 
Posted: 26 April 2008 07:02 AM   [ Ignore ]   [ # 1 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  6551
Joined  04-15-2006

Okay I have a fix, at least for now unless this is a bad thing to do?

CSS

.image-link {
    border
: none !important;
}

HTML Code

<a href="#" title="Link" class="image-link"><img src="http://www.google.co.uk/intl/en_uk/images/logo.gif" alt="Image 1" /></a>

Seems to do it for me! wink

Best wishes,

Mark

 Signature 

Full List Of Plugins Here!! (16)
 
Retrieve Statuses
Maximum Posts Reached
Neat Link
Redirect
Fetch URI

Profile
 
 
Posted: 27 April 2008 08:39 AM   [ Ignore ]   [ # 2 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1455
Joined  09-16-2004

Mark, have you tried this?

a:link img, a:visited img {
    border
: none;
    
text-decoration: none;
}

 Signature 

Peace, e-man.
stookstudio.com, websites built with care and web standards. LinkedIn profile

Profile
 
 
Posted: 27 April 2008 08:51 AM   [ Ignore ]   [ # 3 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  6551
Joined  04-15-2006

Hiya,

Yup was one of the first things I tried. Seems that the only thing that will kill off the line is what I posted above though as it is actually the a which is causing the problem and not the image. As I have an over-riding style for all a links then this is what it is looking at. Giving the a link a class where I don’t want this to happen gets things going the way I want though so I’m happy. wink

Thanks for taking a look at this though.

Best wishes,

Mark

 Signature 

Full List Of Plugins Here!! (16)
 
Retrieve Statuses
Maximum Posts Reached
Neat Link
Redirect
Fetch URI

Profile
 
 
Posted: 27 April 2008 12:00 PM   [ Ignore ]   [ # 4 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  226
Joined  04-23-2004

Hi Mark, I think you’ll need to have the same CSS declaration, that is,

a img {border-bottom: none}

.

 Signature 

Yvonne

———————————
freewheelin.nu | intermezzo | net.textualities

Profile
 
 
Posted: 27 April 2008 01:37 PM   [ Ignore ]   [ # 5 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  6551
Joined  04-15-2006

Nope tried that too wink The only way I can get it to work is to place a class on the a href and take off the inherited styles. Did seem a little weird but really the only way I can get it to work.

Best wishes,

Mark

 Signature 

Full List Of Plugins Here!! (16)
 
Retrieve Statuses
Maximum Posts Reached
Neat Link
Redirect
Fetch URI

Profile
 
 
Posted: 27 April 2008 05:16 PM   [ Ignore ]   [ # 6 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  121
Joined  02-27-2008

Hey Mark,

If I read correctly what you’re saying, the problem is when you hover on the image that is linked you’re getting the bottom border on the image, and that isn’t what you want. Perhaps I’m missing something, but I don’t see where anyone mentioned setting the properties on the hover, such as:

a:hover img {
    border
:none;
}


If that didn’t work, then I’d say have a class that you use on images, which I think you said was the solution you’re currently using.

Profile
 
 
Posted: 27 April 2008 08:39 PM   [ Ignore ]   [ # 7 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  371
Joined  02-26-2008
Mark Bowen - 26 April 2008 07:02 AM

Okay I have a fix, at least for now unless this is a bad thing to do?

CSS

.image-link {
    border
: none !important;
}

Hey Mark…

That’s probably the only way to do it—to apply a seperate class to the anchor.  The issue here is that the image doesn’t have the border, the anchor does.

In your CSS, you’re adding a border to the <a> tag.  The text/image inside the <a></a> tag isn’t what has the border.  So you can’t get rid of it by doing

a img {
   border
:none;
}

The only way would be to get rid of the original border on the anchor, as you have done. 

Hope that explains it for you. :D

Profile
 
 
Posted: 27 April 2008 09:23 PM   [ Ignore ]   [ # 8 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  866
Joined  04-14-2007

@ VisualBinary

Ya beat me to the punch.  grin  Perfect explanation.

 Signature 

Michael Rubens | hothousegraphix
Making the simple complicated is commonplace; making the complicated simple, awesomely simple, that’s creativity. - Charles Mingus

Profile
 
 
Posted: 28 April 2008 02:48 AM   [ Ignore ]   [ # 9 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  6551
Joined  04-15-2006

Hi everyone,

Yep that’s what I thought and the reason for the class on the a link that I found out wink

a:hover img again won’t work for the very reasons mentioned above. The reason it took me a while to figure it out was that I was looking at the hierarchy of what I was trying to do incorrectly. When you are up late at night and seeing these things then it does indeed look like a img but it most definitely isn’t as it is the a link which is doing it so a class is the only way of getting rid of it.

Thanks again.

Best wishes,

Mark

 Signature 

Full List Of Plugins Here!! (16)
 
Retrieve Statuses
Maximum Posts Reached
Neat Link
Redirect
Fetch URI

Profile
 
 
Posted: 21 May 2008 03:14 PM   [ Ignore ]   [ # 10 ]  
Summer Student
Total Posts:  11
Joined  05-21-2008

This got rid of the line under the graphic, but when you go to click on it, ooops, there is the line and the background color since my text links have that.

So now, how to get rid of a hovers and hover badkgrounds?  :-O

Profile
 
 
Posted: 22 May 2008 02:27 AM   [ Ignore ]   [ # 11 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  881
Joined  02-15-2008

Can you post an example page? If I understand what you need correctly, this should get rid of underlines and backgrounds on hover and active (during the click):

a:hover,a:active{text-decoration:none;background-color:transparent;}

 Signature 

Andy Harris | Pepper Digital | Malvern, UK | Twitter | New to ExpressionEngine? Start here!
Remember - If at first you don’t succeed, you’re not Chuck Norris

Profile
 
 
Posted: 22 May 2008 05:58 AM   [ Ignore ]   [ # 12 ]  
Summer Student
Total Posts:  11
Joined  05-21-2008
Andy Harris - 22 May 2008 02:27 AM

Can you post an example page? If I understand what you need correctly, this should get rid of underlines and backgrounds on hover and active (during the click):

a:hover,a:active{text-decoration:none;background-color:transparent;}

Well sure it does, but then, it gets rid of it on the text links and that is where I want it to have a hover background.

This is for img only… there must be a way.

For me, the img is in a td with class=side

Is there some way to do this with img in the td.side?

I am bad at CSS because it makes no sense to me.

Profile
 
 
Posted: 22 May 2008 06:03 AM   [ Ignore ]   [ # 13 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  6551
Joined  04-15-2006
Webgurl - 22 May 2008 05:58 AM

I am bad at CSS because it makes no sense to me.

That probably isn’t going to help then is it? wink

In all seriousness though. Do you have a link to the page showing the problem at all. Would be much easier if we have something to work with. It may be the outline property that you need to set different to get it working the way you want but if you can provide a link then that would help a lot. If you can’t provide a link to the actual site then you can always copy-paste the code to a new html file and upload that somewhere else instead just so that we can get a look.

Best wishes,

Mark

 Signature 

Full List Of Plugins Here!! (16)
 
Retrieve Statuses
Maximum Posts Reached
Neat Link
Redirect
Fetch URI

Profile
 
 
Posted: 22 May 2008 06:04 AM   [ Ignore ]   [ # 14 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  881
Joined  02-15-2008

You can target the image with:

td.side img{}

Then you can manipulate the background with CSS. It’d be easier to help if you had an example of the page though, as I’m a little unsure of what your problem actually is.

It might be that you just need to do what Mark did above if the problem you’re having is to do with hover state on an image.

 Signature 

Andy Harris | Pepper Digital | Malvern, UK | Twitter | New to ExpressionEngine? Start here!
Remember - If at first you don’t succeed, you’re not Chuck Norris

Profile
 
 
Posted: 22 May 2008 06:06 AM   [ Ignore ]   [ # 15 ]  
Summer Student
Total Posts:  11
Joined  05-21-2008

Ohhhhhhhhh this works, is it legal?


#img a:hover,a:active{text-decoration:none;background-color:transparent;}


And then the img tag must be surrounded with the div=“img” /div tag…

It’s just that I don’t usually use divs because I don’t know what that means.

The page is not online.

So my text links have this:

a {font-family: arial,verdana,helvetica; text-decoration: none; border-bottom: dotted 1px; border-color: #999999; font-weight: regular; color: #000066; }
a:visited {font-family: arial,verdana,helvetica; text-decoration: none; border-bottom: dotted 1px; border-color: #999999; font-weight: regular; color: #ff6600;}
a:hover  {font-family: arial,verdana,helvetica; text-decoration: none; border-bottom: dotted 1px; border-color: #999999; font-weight: regular; color: #33aa33;  background: #fedcba;}
a:active  {font-family: arial,verdana,helvetica; text-decoration: none; border-bottom: dotted 1px; border-color: #999999; font-weight: regular; color: #cc0000;}


And now I have this tag there too:

#img a:hover, a:active {text-decoration:none;background-color:transparent;}

And around the images I have

<div="img"></div>

And text links can have a hover and underline embellishment co-existing on the same page with images that do not.

grin

Profile
 
 
Posted: 22 May 2008 06:12 AM   [ Ignore ]   [ # 16 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  881
Joined  02-15-2008

The code should be:

<div id="img"></div>

But yep, that’d work fine. Though if you’re using it more than once on a page you should change it to a class (<div class=“img”> rather than <div id=“img”>).

Otherwise cool!

 Signature 

Andy Harris | Pepper Digital | Malvern, UK | Twitter | New to ExpressionEngine? Start here!
Remember - If at first you don’t succeed, you’re not Chuck Norris

Profile
 
 
Posted: 22 May 2008 06:23 AM   [ Ignore ]   [ # 17 ]  
Summer Student
Total Posts:  11
Joined  05-21-2008

The bad news is, if I put a second image w/link near it, it won’t work. I wonder why?

How do I write it in for say, the td or nav class?

All images should have no underline, no hover..universally.

There must be a way.

Profile
 
 
Posted: 22 May 2008 06:26 AM   [ Ignore ]   [ # 18 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  881
Joined  02-15-2008

To be honest, what you really need to do is to get hold of a good CSS book (CSS Mastery is a good one) and learn how CSS works.

Without being able to see your code it’s hard to pinpoint the problem you see.

 Signature 

Andy Harris | Pepper Digital | Malvern, UK | Twitter | New to ExpressionEngine? Start here!
Remember - If at first you don’t succeed, you’re not Chuck Norris

Profile
 
 
   
1 of 2
1
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1149, on July 16, 2007 09:33 AM
Total Registered Members: 64931 Total Logged-in Users: 48
Total Topics: 81892 Total Anonymous Users: 30
Total Replies: 440217 Total Guests: 254
Total Posts: 522109    
Members ( View Memberlist )
Newest Members:  usharurblaisdellLevagstudioigotthelemonmileswkakiharaAurelsbhairabEric Gun