Style Sheets
  Home arrow Style Sheets arrow Page 4 - CSS: Pseudo
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
STYLE SHEETS

CSS: Pseudo
By: James Payne
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 3 stars3 stars3 stars3 stars3 stars / 3
    2008-05-19

    Table of Contents:
  • CSS: Pseudo
  • Dealing with the :first Line Pseudo Element
  • Pseudo Classes
  • A Preview of Mouse-over Effects

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    CSS: Pseudo - A Preview of Mouse-over Effects


    (Page 4 of 4 )

    We can also create certain mouse-over effects in CSS, displaying a special effect when someone hovers over an image. Below we will change the opacity of an image when the user hovers over a picture of a gorilla or clicks on it:


    <html>

    <head>

    <style type="text/css">

    img

    {

    -moz-opacity:0.4;filter:alpha(opacity=100);"

    }

    </style>

    </head>

    <body>

    <h1>Hover or click on the images...</h1>

    <img src="gorilla.jpg" width="150" height="115" alt="Gorilla"

    onmouseover="this.style.MozOpacity=1;this.filters.alpha.opacity=50"

    onmouseout="this.style.MozOpacity=0.4;this.filters.alpha.opacity=100"

    onmousedown="this.style.MozOpacity=0.4;this.filters.alpha.opacity=0" />

    <img src="girlrilla.jpg" width="150" height="115" alt="Girlrilla"

    onmouseover="this.style.MozOpacity=1;this.filters.alpha.opacity=50"

    onmouseout="this.style.MozOpacity=0.4;this.filters.alpha.opacity=100"

    onmousedown="this.style.MozOpacity=0.4;this.filters.alpha.opacity=0" />

    </body>

    </html>

    We can of course do the opposite, and have the image appear hazy first, then vibrant when the user hovers or clicks on it:


    <html>

    <head>

    <style type="text/css">

    img

    {

    -moz-opacity:0.4;filter:alpha(opacity=50);"

    }

    </style>

    </head>

    <body>

    <h1>Hover or click on the images...</h1>

    <img src="gorilla.jpg" width="150" height="115" alt="Gorilla"

    onmouseover="this.style.MozOpacity=1;this.filters.alpha.opacity=100"

    onmouseout="this.style.MozOpacity=0.4;this.filters.alpha.opacity=50-"

    onmousedown="this.style.MozOpacity=0.4;this.filters.alpha.opacity=75" />

    <img src="girlrilla.jpg" width="150" height="115" alt="Girlrilla"

    onmouseover="this.style.MozOpacity=1;this.filters.alpha.opacity=100"

    onmouseout="this.style.MozOpacity=0.4;this.filters.alpha.opacity=50"

    onmousedown="this.style.MozOpacity=0.4;this.filters.alpha.opacity=75" />

    </body>

    </html>

    There are many different ways to affect images using the CSS filters, and while we will preview some of them here, we will cover them in even greater detail in our next article.

    In our next example, we will preview the blur effect. When the user hovers over the gorilla picture, it will become blurred:


    <html>

    <head>

    <style type="text/css">

    a:hover img {filter: blur(add = 0, direction = 200, strength = 10)}</style>

    </head>

    <body>

    <h1>Hover over the image to make it all blurry-like</h1>

    <a href="http://www.developershed.com">

    <img src="gorilla.jpg" width="150" height="150"/>

    </a>

    </body>

    </html>

    Another filter is the Invert, which, in this case, inverts the color of your image:


    <html>

    <head>

    <style type="text/css">

    a:link img

    {filter:none;}

    a:hover img

    {filter:invert;}

    </style>

    </head>

    <body>

    <h1>Inverting Your Image Colors</h1>

    <a href="http://www.devshed.com">

    <img src="gorilla.jpg" width="150" height="150" alt="Gorilla">

    </body>

    </html>

    We can of course start the image out inverted and show the image as normal when the user hovers over it:


    <html>

    <head>

    <style type="text/css">

    a:link img

    {filter:invert;}

    a:visited img

    {filter:invert;}

    a:hover img

    {filter:none;}

    </style>

    </head>

    <body>

    <h1>Guess what this image is...Hover over it to see if you were right!</h1>

    <a href="http://www.devshed.com">

    <img src="klematis.jpg" width="150" height="150">

    </body>

    </html>

    Well that's all the time we have for this episode. Be sure to join us next time when we go in-depth on working with images, creating a gallery, and applying filters to your photos.

    Till then...


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

       · would have liked to comment, but keep it to myself now, as i dont like the attribute...
     

    STYLE SHEETS ARTICLES

    - Improving the Visual Presentation of a CSS D...
    - Fixing Browser Incompatibilities in a CSS Dr...
    - Building Clean Drop-Down Menus with CSS
    - Creating Hybrid Web Page Layouts with Negati...
    - Creating Three-Column Web Page Layous with N...
    - Swapping Column Positions in Web Page Layout...
    - Creating Web Page Layouts with Negative Marg...
    - Creating Gradients for Individual Containers...
    - Creating Gradients for Web Page Headers with...
    - SEO Scrolling Frames Problem Solved
    - Building Cross-Browser Background Effects wi...
    - CSS: Pseudo
    - Using PNG Images to Build Background Effects
    - CSS: Continuing the Clarification of CSS Cla...
    - CSS: Top Secret Classification






    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
    Stay green...Green IT