width working in IE but not FF

This is a discussion on "width working in IE but not FF" within the Web Page Design section. This forum, and the thread "width working in IE but not FF are both part of the Design Your Website category.



Go Back   Webforumz.com > Main Forums > Design Your Website > Web Page Design

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old May 28th, 2007, 16:09
New Member
Join Date: Jan 2006
Age: 48
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
width working in IE but not FF

I'm used to Firefox displaying CSS correctly and IE being a royal pain, so this particular issue came as a surprise: I can't get FF to display the declared width of a hyperlink. Here's the relevant code:

Code: Select all
<STYLE TYPE="text/css">
A.nav {
    width: 80px;
    background-color: #C0C0D0;
}

A.nav:hover {
    width: 80px;
    background-color: #D0D0DC;
}
</style>
And the link tag says:

Code: Select all
<A  href="#" class="nav">Products</A>
This displays fine in ie, but FF just refuses to display any width other than the width of the linked text itself. I tried using min-width and _width, but no luck.

Using FF 2.0, ie 7.

!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"

Anybody got a clue?
Reply With Quote

  #2 (permalink)  
Old May 28th, 2007, 16:25
karinne's Avatar
SuperMember

SuperMember
Join Date: Jan 2007
Location: You know where
Age: 31
Posts: 4,617
Thanks: 0
Thanked 0 Times in 0 Posts
Re: width working in IE but not FF

That's because the a element is not a block-level (like div) element, so in this instance, FF is right (again)

Add a display: block; to a.nav and you should be fine.

Last edited by karinne; May 28th, 2007 at 16:28.
Reply With Quote
  #3 (permalink)  
Old May 28th, 2007, 16:32
New Member
Join Date: Jan 2006
Age: 48
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Re: width working in IE but not FF

Hmm - OK, you're right (and thanks for the feedback), but the thing is, I don't want it to be a block. That causes the link to be displayed all by it's lonesome, on a line by itself. But I want to use a graphic as a bullet next to the link - IOW to use the default display:inline element.

I played around with a bunch of display: arguments but haven't found one that works. I'm about to give up and use a table to force the alignment, which will make me weep uncontrollably for at least 3 seconds.
Reply With Quote
  #4 (permalink)  
Old May 28th, 2007, 16:39
karinne's Avatar
SuperMember

SuperMember
Join Date: Jan 2007
Location: You know where
Age: 31
Posts: 4,617
Thanks: 0
Thanked 0 Times in 0 Posts
Re: width working in IE but not FF

Well ... this is a menu then? You should be using a unordered list for this (<ul>). And just float the li element to the left, set up a width and display: block in the a.

As for the bullet, put it as a background.

Code: Select all
.somenamehere ul {
	list-style: none;
}

.somenamehere ul li {
        float: left;
	padding: 2px 0 2px 20px;
	background: #001d1d url(/i/bullets/link.jpg) no-repeat 0 3px;
}
.somenamehere ul li a {
        width: 80px;
        display: block;
        font-size: 15px;
}
etc,....
Reply With Quote
  #5 (permalink)  
Old May 28th, 2007, 16:49
New Member
Join Date: Jan 2006
Age: 48
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Re: width working in IE but not FF

Ah - that explains everything. I started out trying to write

ul.nav {}

li.nav {}

...etc. Bad syntax doesn't work, for some odd reason.

Thanks a lot!
Reply With Quote
  #6 (permalink)  
Old May 28th, 2007, 17:10
New Member
Join Date: Jan 2006
Age: 48
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Re: width working in IE but not FF

*sigh*

Well, that didn't work either. To heck with it, I'm using tables.
Reply With Quote
  #7 (permalink)  
Old May 28th, 2007, 17:10
karinne's Avatar
SuperMember

SuperMember
Join Date: Jan 2007
Location: You know where
Age: 31
Posts: 4,617
Thanks: 0
Thanked 0 Times in 0 Posts
Re: width working in IE but not FF

The code you posted above would imply the html below

Code: Select all
<ul class="nav">
  <li class="nav">
 .....
and yes ... bad syntax
Reply With Quote
  #8 (permalink)  
Old May 28th, 2007, 17:11
karinne's Avatar
SuperMember

SuperMember
Join Date: Jan 2007
Location: You know where
Age: 31
Posts: 4,617
Thanks: 0
Thanked 0 Times in 0 Posts
Re: width working in IE but not FF

Quote:
Originally Posted by Davka View Post
*sigh*

Well, that didn't work either. To heck with it, I'm using tables.
well ... hold on a minute now ... give us a link so we can help!!! (as per the guidelines for post)

PLEASE READ: How and When to post your question!
Reply With Quote
  #9 (permalink)  
Old May 29th, 2007, 02:06
spinal007's Avatar
Moderator
Join Date: Mar 2004
Location: Good Ol'London
Age: 22
Posts: 1,620
Blog Entries: 1
Thanks: 0
Thanked 2 Times in 2 Posts
Send a message via ICQ to spinal007 Send a message via MSN to spinal007 Send a message via Yahoo to spinal007 Send a message via Skype™ to spinal007
Re: width working in IE but not FF

IT'S EASY KIDS! Use float!
ul.nav{ whatever }
ul.nav li{ width:120px; } /* or whatever */
ul.nav li a{ display:block; float:left; } /* now the link with fill the entire li */

if that fails, add the following:
ul.nav li a{ width:100%; }
(I'm only saying this because I haven't tested it)
Last Blog Entry: Random String in Javascript (Apr 21st, 2008)

Last edited by spinal007; May 29th, 2007 at 02:09.
Reply With Quote
  #10 (permalink)  
Old May 29th, 2007, 02:09
spinal007's Avatar
Moderator
Join Date: Mar 2004
Location: Good Ol'London
Age: 22
Posts: 1,620
Blog Entries: 1
Thanks: 0
Thanked 2 Times in 2 Posts
Send a message via ICQ to spinal007 Send a message via MSN to spinal007 Send a message via Yahoo to spinal007 Send a message via Skype™ to spinal007
Re: width working in IE but not FF

Quote:
Originally Posted by Davka View Post
*sigh*
Well, that didn't work either. To heck with it, I'm using tables.
Blasphemy!
Last Blog Entry: Random String in Javascript (Apr 21st, 2008)
Reply With Quote
  #11 (permalink)  
Old May 29th, 2007, 09:40
Ryan Fait's Avatar
SuperMember

SuperMember
Join Date: May 2006
Location: Las Vegas
Posts: 3,786
Thanks: 0
Thanked 0 Times in 0 Posts
Re: width working in IE but not FF

Try:

Code: Select all
#nav ul {
  width: 400px;
  height: 24px;
  margin: 0 auto;
  text-align: center;
}
#nav ul li {
  float: left;
}
#nav ul a {
  width: 100px;
  height: 24px;
  display: block;
  float: left;
}
Reply With Quote
Reply

Tags
css, firefox, width

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
div width drappendix Web Page Design 2 Aug 22nd, 2007 14:34
div width drappendix Web Page Design 4 Aug 21st, 2007 04:46
Input width PicoDeath Web Page Design 3 Jul 31st, 2007 16:03
set CORRECT width for <img/> iersel Web Page Design 8 Jul 27th, 2006 07:33
Max-Width in All Browsers purus Web Page Design 4 May 16th, 2005 22:12


All times are GMT. The time now is 21:19.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43