Today's Posts Follow Us On Twitter! TFL Members on Twitter  
Forum search: Advanced Search  
Navigation
Marketplace
  Members Login:
Lost password?
  Forum Statistics:
Forum Members: 24,254
Total Threads: 80,792
Total Posts: 566,472
There are 1216 users currently browsing (tf).
 
  Our Partners:
 
  TalkFreelance     Design and Development     HTML/XHTML/DHTML/CSS :

CSS Rollovers?

Thread title: CSS Rollovers?
Closed Thread  
Page 1 of 2 1 2 >
    Thread tools Search this thread Display Modes  
06-21-2006, 01:47 AM
#1
blindchild02 is offline blindchild02
blindchild02's Avatar
Status: TF Veteran
Join date: Jan 2005
Location:
Expertise:
Software:
 
Posts: 3,258
iTrader: 2 / 100%
 

blindchild02 is on a distinguished road

  Old  CSS Rollovers?

What's the easiest way to do image rollovers (with links)

(and without text)

06-21-2006, 03:00 AM
#2
sliceandcode is offline sliceandcode
Status: Request a custom title
Join date: Aug 2004
Location: California
Expertise:
Software:
 
Posts: 1,004
iTrader: 0 / 0%
 

sliceandcode is on a distinguished road

  Old

I usually do it like this:

<a href="#" class="button">Text Here</div>

css:

.button:link {
background: url('images/button.jpg') no-repeat top;
width: 100px;
height: 10px;
text-indent: -10000px;
}

.button:hover {
background: url('images/button.jpg') no-repeat bottom;
width: 100px;
height: 10px;
text-indent: -10000px;
}

Something like that. In this, I would have a 20px buttom image with the before state at the top and hover state at the bottom.

Edit: I did this kinda quick, you might have to put it in a div. Try it out though.

06-21-2006, 03:13 AM
#3
blindchild02 is offline blindchild02
blindchild02's Avatar
Status: TF Veteran
Join date: Jan 2005
Location:
Expertise:
Software:
 
Posts: 3,258
iTrader: 2 / 100%
 

blindchild02 is on a distinguished road

  Old

would it still work without the 'text here' part, because i just want to do an image rollover with no text

06-21-2006, 03:31 AM
#4
MattL is offline MattL
Status: I love this place
Join date: Jan 2006
Location: BC, Canada
Expertise:
Software:
 
Posts: 583
iTrader: 1 / 100%
 

MattL is on a distinguished road

Send a message via MSN to MattL

  Old

I have used this on a few designs for the navigation and it works great: http://www.wellstyled.com/css-nopreload-rollovers.html

06-21-2006, 03:51 AM
#5
blindchild02 is offline blindchild02
blindchild02's Avatar
Status: TF Veteran
Join date: Jan 2005
Location:
Expertise:
Software:
 
Posts: 3,258
iTrader: 2 / 100%
 

blindchild02 is on a distinguished road

  Old

Originally Posted by MattL
I have used this on a few designs for the navigation and it works great: http://www.wellstyled.com/css-nopreload-rollovers.html
how do you link the image with that??
i need one without text links, i need the image to be clickable, and image changed when hovered

06-21-2006, 06:06 AM
#6
Andrew R is offline Andrew R
Status: Request a custom title
Join date: Dec 2005
Location: Arizona
Expertise:
Software:
 
Posts: 5,200
iTrader: 17 / 95%
 

Andrew R is on a distinguished road

  Old

This is the most logical way of doing it. I know another way but you would have to use divs or something of the sort, so this just cuts down on the code.

Code:
<a href="#"><img src="images/logo1.gif" onMouseover="this.src='images/logo2.gif'" /></a>

06-21-2006, 04:01 PM
#7
blindchild02 is offline blindchild02
blindchild02's Avatar
Status: TF Veteran
Join date: Jan 2005
Location:
Expertise:
Software:
 
Posts: 3,258
iTrader: 2 / 100%
 

blindchild02 is on a distinguished road

  Old

heh, you forgot the onMouseout property, but i added it, and it worked, thanks alot

06-21-2006, 04:05 PM
#8
Andrew R is offline Andrew R
Status: Request a custom title
Join date: Dec 2005
Location: Arizona
Expertise:
Software:
 
Posts: 5,200
iTrader: 17 / 95%
 

Andrew R is on a distinguished road

  Old

Oh, yeah. I did that really quick.

No problem.

06-21-2006, 04:14 PM
#9
Jeff Andersen is offline Jeff Andersen
Status: Superstar
Join date: Apr 2005
Location:
Expertise:
Software:
 
Posts: 4,449
iTrader: 10 / 100%
 

Jeff Andersen is on a distinguished road

  Old

When i do navigations, it's always with an unorderedlist but with images as the link.
Same thing can be done say with a heading..

Here is the example for an unordered list:

Code:
<ul id="nav">
<li><a href="" id="homepage">Homepage</a></li>
<li><a href="" id="pageone">Page one</a></li>
</ul>
Then for CSS you need to set the initial UL and LI properties:

Code:
#nav {
	list-style-type: none;
}

#nav li a {
	display: block;
	overflow: hidden;
	padding: #px 0 0;
	width: #px;
	height: 0;
}
And here is the CSS for the initial button and rollover button:

Code:
#nav li a#homepage {
	background: url('images/homepage.gif') no-repeat 0 0;
}

#nav li a#homepage:hover {
	background: url('images/homepage-over.gif') no-repeat 0 0;
}

#nav li a#pageone {
	background: url('images/pageone.gif') no-repeat 0 0;
}

#nav li a#pageone:hover {
	background: url('images/pageone-over.gif') no-repeat 0 0;
}

Padding is where you set the height, width is width.

I tend to use one image for all buttons to save from loading and that's where the two zero's at the end come in, changing it to #px to set the spot in the image the button resides (say if the button was 150 pixels wide, and you had five buttons, the first button's normal state stays at zero, then the rollover would be at -750px).

06-21-2006, 04:48 PM
#10
Andrew R is offline Andrew R
Status: Request a custom title
Join date: Dec 2005
Location: Arizona
Expertise:
Software:
 
Posts: 5,200
iTrader: 17 / 95%
 

Andrew R is on a distinguished road

  Old

Jeff, that is what I do but I wasn't sure if he was doing a navigation or a simple one image rollover so I gave him a code to do just that.

Good job at posting that though. Really helpful to some people.

Closed Thread  
Page 1 of 2 1 2 >


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

  Posting Rules  
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump:
 
  Contains New Posts Forum Contains New Posts   Contains No New Posts Forum Contains No New Posts   A Closed Forum Forum is Closed