www.webdeveloper.com
Recent Articles
  • Finding Slow Running Queries in ASE 15
  • A More Advanced Pie Chart for Analysis Services Data
  • Adobe AIR Programming Unleashed: Working with Windows
  • Performance Testing SQL Server 2008's Change Data Capture Functionality
  • The ABC's of PHP: Introduction to PHP
  • How to Migrate from BasicFiles to SecureFiles Storage
  • Why the Twitter Haters Are Wrong
  • User Personalization with PHP: Beginning the Application
  • Whats in an Oracle Schema?
  • Lighting Enhancement in Photoshop
  •  

    Go Back   WebDeveloper.com > Client-Side Development > CSS

    CSS Discussion and technical support relating to Cascading Style Sheets.

    Reply
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1  
    Old 04-25-2005, 08:13 AM
    lightsout lightsout is offline
    Registered User
     
    Join Date: Apr 2005
    Posts: 1
    Angry Baffled by simple image rollover class. Pls help!

    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...
    Reply With Quote
      #2  
    Old 04-25-2005, 08:36 AM
    scragar's Avatar
    scragar scragar is offline
    Some Random Guy
     
    Join Date: Jun 2003
    Location: here
    Posts: 4,460
    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.
    Reply With Quote
      #3  
    Old 04-25-2005, 08:56 AM
    bathurst_guy's Avatar
    bathurst_guy bathurst_guy is offline
    Super Moderator
     
    Join Date: Apr 2005
    Location: Bathurst, NSW, Australia
    Posts: 3,350
    <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.
    Reply With Quote
      #4  
    Old 04-25-2005, 10:42 AM
    Fang's Avatar
    Fang Fang is offline
    Resistance is futile
     
    Join Date: Apr 2003
    Location: Netherlands
    Posts: 17,224
    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
    Reply With Quote
      #5  
    Old 04-26-2005, 12:43 AM
    bathurst_guy's Avatar
    bathurst_guy bathurst_guy is offline
    Super Moderator
     
    Join Date: Apr 2005
    Location: Bathurst, NSW, Australia
    Posts: 3,350
    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.
    Reply With Quote
      #6  
    Old 04-26-2005, 03:38 AM
    BonRouge's Avatar
    BonRouge BonRouge is offline
    Winemaster
     
    Join Date: Jul 2004
    Location: Sendai, Japan
    Posts: 1,275
    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.
    Reply With Quote
    Reply

    Bookmarks


    Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
     
    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is Off
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 12:19 AM.



    Acceptable Use Policy

    internet.comMediabistrojusttechjobs.comGraphics.com

    WebMediaBrands Corporate Info


    Advertise | Newsletters | Feedback | Submit News

    Legal Notices | Licensing | Permissions | Privacy Policy

    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.