| View previous topic :: View next topic |
| Author |
Message |
Amanda Carter
Joined: 23 Mar 2007 Posts: 1
|
Posted: Sat May 19, 2007 5:56 pm Post subject: JavaScrip type rollover effects with CSS |
|
|
| How do I use CSS to create JavaScript type rollover effects? I have read that it can be done, but no details where given. |
|
| Back to top |
|
 |
SharkZoneDesign
Joined: 17 Mar 2007 Posts: 15 Location: Phoenix, Arizona
|
Posted: Tue May 22, 2007 3:10 pm Post subject: |
|
|
Hello Amanda,
There are four different selectors that apply to links. You can specify separate styles for each of these selectors including color background color and background image. In the example below the link color will vary according to the state.
| Code: |
<html>
<head>
<style type="text/css">
a.alink:link {color: red;}
a.alink:visited {color: green;}
a.alink:active {color: blue;}
a.alink:hover {color: orange;}
</style>
</head>
<body>
<a href="http://digg.com" class="alink">This is a link</a>
</body>
</html>
|
In your case you are probably going to only work with the hover selector. You don't give specifics of what effect you are trying to archive. So I will give an example of a row of menu boxes that change colors with a mouse over.
| Code: |
<html>
<head>
<style type="text/css">
.nav
{
border-top: 1px solid black;
width: 150px;
margin: 0;
padding: 0;
}
.nav li
{
list-style: none;
margin: 0;
padding: 0;
}
.nav a
{
display: block;
padding: 2px 5px 2px 25px;
margin: 0;
border-left: 1px solid black;
border-right: 1px solid black;
border-bottom: 1px solid black;
text-decoration: none;
}
.nav a:link
{
background-color: yellow;
color: red;
}
.nav a:hover
{
background-color: blue;
color: white;
}
</style>
</head>
<body>
<ul class="nav">
<li><a href="#">Link 1</a></li>
<li><a href="#">Link 2</a></li>
<li><a href="#">Link 3</a></li>
</ul>
</body>
</html>
|
Some key points:
Unordered lists are commonly used for menus in CSS based designs,
The list-style attribute is used to block the default bulleted list.
The ”display: block” allows for specifying the size.
The “text-decoration: none” removes the default behavior of an underlined link.
Hope This Helps
Tom Whitney |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|