| Coding Forum Problems with your code? Let's hear about it. |
01-03-2005, 07:48 PM
|
#1 (permalink)
|
|
Senior Member
Join Date: 08-03-04
Posts: 1,077
Latest Blog: None
|
Rollover Effect
I was wondering if you could use Photoshop to create a rollover effect for links. I want to do something along the lines of what this site has at the left side. See how the item goes from white to red when you hover over it? How can I make that?
|
|
|
01-03-2005, 08:17 PM
|
#2 (permalink)
|
|
Contributing Member
Join Date: 10-13-03
Location: Pffffft
Posts: 8,857
Latest Blog: None
|
That's done via CSS.
*Moved to Coding*
|
|
|
01-03-2005, 08:24 PM
|
#3 (permalink)
|
|
No Longer Here
Join Date: 09-27-03
Location: State College, PA
Posts: 9,354
Latest Blog: None
|
You can view source on that page to see how they did it.
<div id="myMenu"><a href="index.php"> ¤ News</a></div>
Then look at the stylesheet to see the css for "myMenu" - abandonia.com/fonts.css
Just look at the three sections of the stylesheet for "#myMenu".
|
|
|
01-03-2005, 09:28 PM
|
#4 (permalink)
|
|
Inactive
Join Date: 05-12-04
Posts: 520
Latest Blog: None
|
You need this code to make the rollover like they did. You will have to
specify your own padding, font, etc
a {
text-decoration: none; /* This turns off underlining */
display: block; /* This makes the rectangle color area */
width: 100%; /* This tell it to be all the width */
}
a:hover { /* This is the rollover effect. */
background-color: #AD0000; /* This changes background color */
color: white; /* Changes the text color */
}
|
|
|
01-04-2005, 12:48 AM
|
#5 (permalink)
|
|
Contributing Member
Join Date: 10-13-03
Location: Belgium
Posts: 316
Latest Blog: None
|
well,
you can if you have photoshop with imageready. You should click the imageready button in photoshop and the image will be transferred to IR where you can add those rollovers. I would not recommend it though, the code is quite messy.
DragonEye
|
|
|
01-04-2005, 04:52 PM
|
#6 (permalink)
|
|
Senior Member
Join Date: 08-03-04
Posts: 1,077
Latest Blog: None
|
Quote:
|
Originally Posted by seonewbee
You need this code to make the rollover like they did. You will have to
specify your own padding, font, etc
a {
text-decoration: none; /* This turns off underlining */
display: block; /* This makes the rectangle color area */
width: 100%; /* This tell it to be all the width */
}
a:hover { /* This is the rollover effect. */
background-color: #AD0000; /* This changes background color */
color: white; /* Changes the text color */
}
|
This looks good. It is css? There will be no other css on the page so do i have to wrap that in <css> or something?
|
|
|
01-04-2005, 05:59 PM
|
#7 (permalink)
|
|
Contributing Member
Join Date: 10-13-03
Location: Pffffft
Posts: 8,857
Latest Blog: None
|
Yah, that's CSS. There is a way to do it besides the adding a new file, but I highly recommend that, cause then when you change one thing it'll be good for all pages.
Then when you make a new page, add this to every page of the site to make it good for the stuff on the page:
<link rel="stylesheet" href="filenameandlocationhere.css" type="text/css">
|
|
|
01-05-2005, 08:41 AM
|
#8 (permalink)
|
|
Inactive
Join Date: 08-06-04
Location: Ontario
Posts: 669
Latest Blog: None
|
There is no <css> tag, but you can either add the css into the document using (inside the <head> tag):
Code:
<style type="text/css">
a {
text-decoration: none; /* This turns off underlining */
display: block; /* This makes the rectangle color area */
width: 100%; /* This tell it to be all the width */
}
a:hover { /* This is the rollover effect. */
background-color: #AD0000; /* This changes background color */
color: white; /* Changes the text color */
}
</style>
Or, as Pimpen said, link to an external stylesheet, which is preferred. It's easier to maintain, and it gets cached that way. So you would save everything between the <style> tags in a file and use the code that Pimp noted in your <head> tag of every page.
|
|
|
01-05-2005, 06:12 PM
|
#9 (permalink)
|
|
No Longer Here
Join Date: 09-27-03
Location: State College, PA
Posts: 9,354
Latest Blog: None
|
FYI: Just using this code that seonewbee posted will make all links on the page have this effect. You need to use classes if you only want this on the nav links.
|
|
|
01-05-2005, 06:17 PM
|
#10 (permalink)
|
|
Senior Member
Join Date: 08-03-04
Posts: 1,077
Latest Blog: None
|
Quote:
|
Originally Posted by Jazzee
FYI: Just using this code that seonewbee posted will make all links on the page have this effect. You need to use classes if you only want this on the nav links.
|
Yes, I want classes. Seems css is something I should spend some time reading about.
Thanks for the help.
|
|
|
01-05-2005, 06:23 PM
|
#11 (permalink)
|
|
No Longer Here
Join Date: 09-27-03
Location: State College, PA
Posts: 9,354
Latest Blog: None
|
Instead of using
a {..stuff here..
and
a:hover {..stuff here..
use
a.nav {..stuff here..
and
a.nav:hover {..stuff here..
Then on your links in the page use
<a class="nav" href="..
|
|
|
01-05-2005, 07:28 PM
|
#12 (permalink)
|
|
Inactive
Join Date: 05-12-04
Posts: 520
Latest Blog: None
|
Has anybody tried targeting?
div.menu a. {
....
}
div.menu a.hover{
....
}
This way you do not have to put a class on every link. You could replace "div" with "td"
What the above means is that a div with the class of menu that contains an anchor / link will look the way you specified. Anchors in other parts of the document will not look this way.
You might want to put your menu in a list
<ul>
<li><a .....>text</a>
<li><a ....>text2</a>
....
</ul>
Have fun
Last edited by seonewbee : 01-05-2005 at 07:57 PM.
|
|
|
01-05-2005, 11:46 PM
|
#13 (permalink)
|
|
Contributing Member
Join Date: 10-13-03
Location: Belgium
Posts: 316
Latest Blog: None
|
You might also consider doing it using XML behaviours
It's a very nice way of doing rollovers, I haven't used the system myself but I have done some tests and I'm definately going to use it on my future sites.
Here is a URL where you can find out:
http://www.w3schools.com/xml/xml_behaviors.asp
DragonEye
|
|
|
01-06-2005, 09:05 PM
|
#14 (permalink)
|
|
Inactive
Join Date: 05-12-04
Posts: 520
Latest Blog: None
|
Doesn't that require javascript? Won't work if javascript is turned off. CSS is better.
|
|
|
01-07-2005, 12:31 AM
|
#15 (permalink)
|
|
Contributing Member
Join Date: 10-13-03
Location: Belgium
Posts: 316
Latest Blog: None
|
Sorry, post removed, already posted it 
|
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 04:35 AM.
© Copyright 2008 V7 Inc
|