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 2316 users currently browsing (tf).
 
  Our Partners:
 
  TalkFreelance     Design and Development     HTML/XHTML/DHTML/CSS :

CSS Rollover Troubles

Thread title: CSS Rollover Troubles
Closed Thread  
Page 1 of 2 1 2 >
    Thread tools Search this thread Display Modes  
02-27-2007, 08:48 PM
#1
NuPixel is offline NuPixel
Status: rawr
Join date: Dec 2005
Location:
Expertise:
Software:
 
Posts: 1,238
iTrader: 0 / 0%
 

NuPixel is on a distinguished road

  Old  CSS Rollover Troubles

Okay, basically I'm trying to code a navigation bar into my layout but am having trouble with it. I would like the nav's BG image and text to change on rollover. I have made up an image showing what it is I would like to have happened. I am not good with CSS so my coding is coming out all incorrectly. If it's not able to happen, don't worry about it, but I appreciate the help I do get. Thanks.

02-27-2007, 09:07 PM
#2
daz is offline daz
Status: I love this place
Join date: Jun 2005
Location: UK
Expertise:
Software:
 
Posts: 562
iTrader: 5 / 100%
 

daz is on a distinguished road

Send a message via MSN to daz

  Old

I coded a similar thing for a client today..try and edit this code.

xhtml
Code:
<ul id="nav">
<li><a href="#" class="navigate">Services</a></li>
<li><a href="#" class="navigate">Specials</a></li>
<li><a href="#" class="navigate">About Us</a></li>
<li><a href="#" class="navigate">Testimonals</a></li>
<li><a href="#" class="navigate">Contact Us</a></li>
</ul>
css
Code:
ul#nav {
	width: 525px;
	height: 29px;
	font-weight: bold;
	text-align: center;
	margin: 10px auto 10px 13px;
}
ul#nav li {
	display: inline;
	list-style: none;
}
ul#nav li a {
	color: #fff;
	padding: 7px 0 0 0;
	margin: 0 13px 0 0;
}
ul#nav li a.navigate {
	width: 92px;
	height: 22px;
	background: url("images/blue.gif") no-repeat;
	float: left;
	text-decoration: none;
}
ul#nav li a.navigate:hover {
	width: 92px;
	height: 22px;
	background: url("images/green.gif") no-repeat;
	float: left;
	text-decoration: none;
}

02-27-2007, 09:28 PM
#3
NuPixel is offline NuPixel
Status: rawr
Join date: Dec 2005
Location:
Expertise:
Software:
 
Posts: 1,238
iTrader: 0 / 0%
 

NuPixel is on a distinguished road

  Old

Wow, thanks a lot daz. I plugged it in and made a few adjustments and it's working fine. Thanks.

02-28-2007, 01:07 AM
#4
Awesome is offline Awesome
Awesome's Avatar
Status: Pastafarian
Join date: May 2006
Location: Duct Taped to your Ceiling
Expertise:
Software:
 
Posts: 3,440
iTrader: 26 / 93%
 

Awesome is on a distinguished road

  Old

You shouldn't have to apply the class to each <li>. Use a broad tag off the <ul> - much less structural markup that way.

03-01-2007, 11:31 AM
#5
Xoligy is offline Xoligy
Status: I'm new around here
Join date: Mar 2007
Location:
Expertise:
Software:
 
Posts: 2
iTrader: 0 / 0%
 

Xoligy is on a distinguished road

  Old

Also, there's no need to re-declare everything in the :hover declaration. It will inherit it from its un-hovered state.

03-01-2007, 10:15 PM
#6
daz is offline daz
Status: I love this place
Join date: Jun 2005
Location: UK
Expertise:
Software:
 
Posts: 562
iTrader: 5 / 100%
 

daz is on a distinguished road

Send a message via MSN to daz

  Old

Originally Posted by Xoligy View Post
Also, there's no need to re-declare everything in the :hover declaration. It will inherit it from its un-hovered state.
I know, but it makes it easier for editing : )

03-01-2007, 11:11 PM
#7
Xi0s is offline Xi0s
Status: Sin Binner
Join date: Dec 2006
Location: Huddersfield, UK
Expertise:
Software:
 
Posts: 384
iTrader: 3 / 83%
 

Xi0s is on a distinguished road

Send a message via MSN to Xi0s

  Old

also li:hover has problems in IE.
Its usually better to put a div around your links, or use the a tag and set a background on that .

03-01-2007, 11:17 PM
#8
bgolat is offline bgolat
Status: I love this place
Join date: Mar 2005
Location:
Expertise:
Software:
 
Posts: 714
iTrader: 0 / 0%
 

bgolat is on a distinguished road

Send a message via ICQ to bgolat Send a message via AIM to bgolat Send a message via Yahoo to bgolat

  Old

make it all 1 image so there isnt a loading lag on rollover as well.

03-01-2007, 11:38 PM
#9
Xi0s is offline Xi0s
Status: Sin Binner
Join date: Dec 2006
Location: Huddersfield, UK
Expertise:
Software:
 
Posts: 384
iTrader: 3 / 83%
 

Xi0s is on a distinguished road

Send a message via MSN to Xi0s

  Old

yeh he has a point, use 1 image, and then change the background-position:, its the best way .

03-02-2007, 01:04 AM
#10
derek lapp is offline derek lapp
Status: design rockstar
Join date: Jan 2005
Location: guelph, ontario
Expertise:
Software:
 
Posts: 2,246
iTrader: 0 / 0%
 

derek lapp is on a distinguished road

  Old

li doesnt have a :hover state. he's not applying it to the list item anyways. and there's no reason to wrap everything in a div. the whole point of tableless is to avoid tag soup.

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