|
|||||||
| CSS Discussion and technical support relating to Cascading Style Sheets. |
![]() |
|
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hello,
I'm trying to create a simple class that will create a 1 pixel border around an image, then when hovered over the 1 pixel border changes color. I cannot find the correct solution that works within Safari on a mac, IE on a mac, or IE in Windows. Any help/workarounds appreciated. Something that works! I'm trying to call the class like so... <a href="mylink.php" class="TSimage"><img src="myimage.jpg"></a> I've tried this: .TSimage a:link {border:1px solid; border-color: #ffffff;} .TSimage a:visited {border:1px solid; border-color: #ffffff;} .TSimage a:hover {border:1px solid; border-color: #cccccc;} .TSimage a:visited {border:1px solid; border-color: #ffffff;} I've tried this: .TSimage {border: 1px solid #ffffff} .TSimage:hover {color: #cccccc} I've tried this: .TSimage a {border: 1px solid #ffffff} .TSimage a:hover {color: #cccccc} Nothing works! Please help! Anyone! Thanks in advance... |
|
#2
|
||||
|
||||
|
for some reason this appears to have a weird border, but it's easier to work with:
Code:
<style>
.TSimage{
border-width: 1px;
border-style: solid;
border-color: #0000ff
}
.TSimage:hover{
border-style: solid;
border-color: #00ff00
}
</style>
<a href="mylink.php"
class="TSimage"><img
src="myimage.jpg"></a>
__________________
If you are using PHP please use the [php] and [/php] forum tags for highlighting... The same applies to HTML and the forums [html][/html] tags. |
|
#3
|
||||
|
||||
|
<style type="text/css">
.tsimage {border: 1px solid #fff} .tsimage:hover {border: 1px solid #ccc} </style> </head> <body> <a href="#nogo"><img class="tsimage" src="file.gif" width="x" height="x" alt="x" /></a></body></html>
__________________
The answer to all these questions is Google. Give your thread a useful title | Webdeveloper.com Acceptable Use Policy Something wrong with your code? Validate first! | No Australian Net Censorship! The Australian government is wanting to follow in China's footsteps and "provide" nationwide Internet censorship, don't let them! Last edited by bathurst_guy; 04-25-2005 at 09:05 AM. |
|
#4
|
||||
|
||||
|
bathurst_guy, IE does not do image hover.
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title>border</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
<!--
.TSimage {
display:block;
background:#ccc url(myimage.jpg) no-repeat;
width:50px; /* width and height of image */
height:25px;
border:1px solid #00f;
}
a.TSimage:hover {
border:1px solid #0f0;
}
-->
</style>
</head>
<body>
<div>
<a href="mylink.php" class="TSimage"></a>
</div>
</body>
</html>
__________________
At least 98% of internet users' DNA is identical to that of chimpanzees |
|
#5
|
||||
|
||||
|
I Think It Does. Your way would take ages, you would have to make a different class for each image.
Try this: <style type="text/css"> a:link {color: #998080;} a:visited {color: #666;} a:hover {color: #000;} a img {border: none;} .tsImg img{ border: 1px solid #fff; } .tsImg a:hover img{ border: 1px solid #ccc; } </style> </head> <body> <div class="tsImg"> <p><a href="#nogo"><img src="img1.gif" height="10" width="10" alt="image 1" /></a></p> </div> Conditions that I've found (sorry I didn't notice these before my last post): 1. Needs to have basic anchor tags 2. The class needs to have the "Img" at the end of the name (with the capital I) Refer to http://cssvault.com (this is where I found it works on IE and Firefox, I just simplified)
__________________
The answer to all these questions is Google. Give your thread a useful title | Webdeveloper.com Acceptable Use Policy Something wrong with your code? Validate first! | No Australian Net Censorship! The Australian government is wanting to follow in China's footsteps and "provide" nationwide Internet censorship, don't let them! Last edited by bathurst_guy; 04-26-2005 at 01:12 AM. |
|
#6
|
||||
|
||||
|
This seems to work :
Code:
<!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>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=shift_jis" />
<script type="text/javascript">
sfHover = function() {
var sfEls = document.body.getElementsByTagName("IMG");
for (var i=0; i<sfEls.length; i++) {
sfEls[i].onmouseover=function() {
this.className+=" sfhover";
}
sfEls[i].onmouseout=function() {
this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
}
}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);
</script>
<style type="text/css">
.TSimage img{border: 1px solid #fff;}
.TSimage:hover img, .TSimage .sfhover {border: 1px solid #ccc;}
</style>
</head>
<body>
<span class="TSimage"><img src="wine.jpg" alt="wine" /></span>
</body>
</html>
Last edited by BonRouge; 04-26-2005 at 04:44 AM. |
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|