Web Design Forum: CSS Menu Question - Web Design Forum

Jump to content

WDF
WDF Premium Memberships Reseller Hosting
Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

CSS Menu Question

#1 User is offline   JamesW 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 320
  • Joined: 28-July 09
  • Reputation: 2
  • Gender:Male
  • Location:London/Essex, UK
  • Experience:Advanced
  • Area of Expertise:Designer/Coder

Posted 08 January 2010 - 11:06 PM

This is probably really basic but I've never worked out a way around it myself and I'm sure there is one..

ul#nav {background:url(img/nav-bg.jpg) repeat-x top #C18E00;}

ul#nav li {display:block;float:left;}

Because I have floated the list items they are taken out of the flow of the page so I then lose my background image from the UL.

I know I can set a height on my ul#nav but I will be using text in the menu so It needs to be able to expand..

I worked out you can use display:inline-block; instead of using floats but that doesn't work in IE ( Posted Image )

Is there a way around this, or a better technique ?
0

#2 User is offline   gaz545 

  • Dedicated Member
  • PipPip
  • Group: Members
  • Posts: 146
  • Joined: 12-August 09
  • Reputation: 4
  • Gender:Male
  • Experience:Advanced
  • Area of Expertise:Web Developer

Posted 08 January 2010 - 11:58 PM

If you specify a width for both the ul and the li then you can remove float left and fix your issue.
0

#3 User is offline   JamesW 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 320
  • Joined: 28-July 09
  • Reputation: 2
  • Gender:Male
  • Location:London/Essex, UK
  • Experience:Advanced
  • Area of Expertise:Designer/Coder

Posted 09 January 2010 - 12:10 AM

View Postgaz545, on 08 January 2010 - 11:58 PM, said:

If you specify a width for both the ul and the li then you can remove float left and fix your issue.


I'm floating it left so the items are aligned horizontaly though ?
0

#4 User is offline   Wickham 

  • Web Guru
  • View gallery
  • Group: Moderators
  • Posts: 2,875
  • Joined: 11-June 09
  • Reputation: 257
  • Gender:Male
  • Location:Salisbury UK
  • Experience:Intermediate
  • Area of Expertise:Web Developer

Posted 09 January 2010 - 11:17 AM

Try adding overflow: hidden; and a width to the ul style:-
ul#nav {background:url(img/nav-bg.jpg) repeat-x top #C18E00; overflow: hidden; width: ???px; }


NOTE

the ul tag must also have a width; either % or fixed width as item 2d here:-
http://www.wickham43...xbackground.php
0

#5 User is offline   JamesW 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 320
  • Joined: 28-July 09
  • Reputation: 2
  • Gender:Male
  • Location:London/Essex, UK
  • Experience:Advanced
  • Area of Expertise:Designer/Coder

Posted 09 January 2010 - 05:31 PM

Perfect thanks :)

Code I used if anyone else was interested:
ul#nav {background:url(img/nav-bg.jpg) repeat-x top #C18E00;width:890px;padding:5px;overflow:hidden;}

ul#nav li {display:block;float:left;padding:5px 4px;margin:0 5px;}


0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users