Tuesday 3 July 2007

Fluid Horizontal Menu - Using UL, CSS (and a table)

In the A List Apart article: Taming Lists there is a very simple example of using UL to markup a horizontal list. Making this into a fluid full width menu proved much more difficult than I thought, and I have provided the implementation here.

The broad requirements of this are:

  • There is a color for the menu, and another color for the current item. The menu has a bottom border the same color as the current item.
  • The menu must not wrap when browser is resized, it must always be a single horizontal row
  • When browser width is smaller than menu, scrolling the viewport across will still display the menu bottom border
  • When browser width is larger than the menu, the menu expands to 100% width
  • The items in the menu are dynamically generated on the server (so the number of items may vary, as can the total possible width)
Show below, is the screenshot of the final product.

The final code to produce this menu is as follows:

<style type="text/css">
li, ul {
   padding: 0;
   margin:0;
}
table.menu {
   background-color: #CCC;
   border-bottom: 5px solid #8C78C5;
   width: 100%;
   padding: 0;
   border-collapse:collapse;
}
table.menu td, table.menu tr {
   border: 0; padding: 0;
}
table.menu ul {
   white-space: nowrap;
   padding: 4px 0px;
}
table.menu li{
   display: inline;
   list-style: none;
}
table.menu a{
   background-color: #CCC;
   padding: 4px 10px;
   color: black;
   text-decoration: none;
   border-left: 1px solid white;
}
table.menu a:hover {
   text-decoration: underline;
}
table.menu a.first {
   border-left: none;
}
table.menu a.current{
   color: white;
   background-color: #8C78C5;
}
</style>

<!--[if IE]>
<style type="text/css">
table.menu ul{
   width:110%;
}
</style>
<![endif]-->

<table class="menu"><tr><td><!--
  --><ul><!--
  --><li><a href="#" class="first">Spring MVC framework</a></li><!--
  --><li><a href="#">Struts MVC</a></li><!--
  --><li><a href="#" class="current">Tapestry</a></li><!--
  --><li><a href="#">JSF</a></li><!--
  --><li><a href="#">Java Server Pages</a></li><!--
  --></ul><!--
--></td></tr></table>

To summarise the main points of the implementation:

  • The LI are inline, and the UL has white-space:nowrap so that the items are in a single row
  • The background-color is defined in the anchor so that the entire "tab" is clickable
  • To increase the height of each "tab", add padding to the anchor, and also to the UL because the anchors are inline elements
  • We need the container to expand to accomodate its content regardless of browser viewport size, so that the bottom border stretches with the content. A table is used because IE doesn't suppport display:table* attributes
  • Whitespace is commented out because for some reason compliant browsers render a gap
  • An IE only rule is provided to solve a problem which appears to be collapsing related.

For the full explaination of this menu, see my article Fluid Horizontal Menu - Using Unordered List, XHTML, CSS (and a table)

This menu has been tested on IE6, IE7, Firefox 2, Opera 9, and Safari 3beta

263 comments:

«Oldest   ‹Older   201 – 263 of 263
Anonymous said...

Its like you read my mind! You seem to know a lot about this, like you wrote the book in it or something.
I think that you can do with a few pics to drive the message home
a bit, but other than that, this is fantastic blog. An
excellent read. I'll certainly be back.

My web blog Options trading education

Anonymous said...

I just like the valuable information you provide to your articles.

I will bookmark your blog and check again here frequently.
I am reasonably sure I will be informed a lot of new stuff proper here!
Best of luck for the next!

Look at my web site http://www.youtube.com/watch?v=9SnPSlwYwpQ

Anonymous said...

Hello just wanted to give you a quick heads up. The text in your article seem
to be running off the screen in Firefox. I'm not sure if this is a formatting issue or something to do with internet browser compatibility but I figured I'd post to let you know.
The layout look great though! Hope you get the issue resolved soon.
Thanks

Here is my blog :: tsx after hours trading

Anonymous said...

Good day! Do you know if they make any plugins to assist with SEO?
I'm trying to get my blog to rank for some targeted keywords but I'm not seeing
very good results. If you know of any please share.
Thank you!

Here is my blog - ways to earn extra money online

Anonymous said...

Keep this going please, great job!

Here is my blog post - make money now

Anonymous said...

This piece of writing will assist the internet users for creating
new webpage or even a weblog from start to end.

Feel free to surf to my blog ... 28 ways to make money online

Anonymous said...

I'm truly enjoying the design and layout of your site. It's a very easy
on the eyes which makes it much more pleasant for me to come here and
visit more often. Did you hire out a designer to create your theme?
Excellent work!

My web page cedarfinance

Anonymous said...

Hi! I've been following your web site for a long time now and finally got the bravery to go ahead and give you a shout out from Dallas Texas! Just wanted to mention keep up the good job!

Review my web blog - how 2 make money online

Anonymous said...

Hello! This is kind of off topic but I need some advice from an established blog.

Is it very difficult to set up your own blog? I'm not very techincal but I can figure things out pretty fast. I'm thinking
about setting up my own but I'm not sure where to start. Do you have any tips or suggestions? Many thanks

Also visit my page ... How To Make Some Money Fast

Anonymous said...

I am regular reader, how are you everybody? This paragraph posted at
this website is in fact pleasant.

Feel free to visit my homepage; work At home programs

Anonymous said...

I've been browsing online greater than 3 hours as of late, but I by no means found any attention-grabbing article like yours. It's beautiful worth sufficient for me.
In my view, if all webmasters and bloggers made excellent content as you
probably did, the web will probably be much more helpful than ever before.



Also visit my weblog extra ways to make money from home

Anonymous said...

Unquestionably believe that which you stated. Your favorite justification seemed to be on
the web the easiest thing to be aware of. I say to you, I certainly get annoyed
while people think about worries that they plainly
don't know about. You managed to hit the nail upon the top and defined out the whole thing without having side-effects , people could take a signal. Will probably be back to get more. Thanks

My website; Is Making Money Online Real

Anonymous said...

When I originally commented I clicked the "Notify me when new comments are added" checkbox
and now each time a comment is added I get four emails with the same
comment. Is there any way you can remove people from that service?
Bless you!

my blog; online part time jobs from home

Anonymous said...

Greetings! Quick question that's totally off topic. Do you know how to make your site mobile friendly? My weblog looks weird when viewing from my iphone 4. I'm trying to find
a theme or plugin that might be able to fix this issue.
If you have any suggestions, please share. Thanks!


My weblog: jobs in hot springs ar

Anonymous said...

Wow, that's what I was searching for, what a information! existing here at this webpage, thanks admin of this web site.

Feel free to visit my web blog: binary options brokers

Anonymous said...

Thanks for finally talking about > "Fluid Horizontal Menu - Using UL, CSS (and a table)" < Liked it!

my web blog; http://www.
youtube.com/watch?v=ScFvd7Deva0

Anonymous said...

An interesting discussion is worth comment. I think that
you need to write more on this subject, it might not be
a taboo subject but typically people don't discuss these subjects. To the next! All the best!!

my web blog: http://www.youtube.com/watch?v=ddcKJDTQ7zI

Anonymous said...

It's going to be ending of mine day, however before end I am reading this enormous piece of writing to increase my know-how.

Also visit my webpage; http://www.youtube.com/watch?v=caSEY6ykNKw

Anonymous said...

Its like you read my thoughts! You appear to grasp so much about this,
such as you wrote the e book in it or something.
I feel that you just can do with some % to drive the message home a little bit, but instead of that, that is magnificent blog. A great read. I will certainly be back.

My website :: cedarfinance

Anonymous said...

Hey! I know this is kinda off topic nevertheless I'd figured I'd ask.

Would you be interested in trading links or maybe guest authoring a blog article or
vice-versa? My blog goes over a lot of the same subjects as yours and I feel we could greatly benefit from each
other. If you happen to be interested feel free to shoot me an
e-mail. I look forward to hearing from you!
Fantastic blog by the way!

my webpage - cedar finance to live off of

Anonymous said...

Admiring the dedication you put into your blog and in depth information you provide.

It's awesome to come across a blog every once in a while that isn't
the same unwanted rehashed information. Great read! I've saved your site and I'm adding your RSS feeds to my Google account.


Stop by my website; http://www.youtube.com/watch?v=fCkK9-pzu_o

Anonymous said...

I pay a visit everyday some web sites and websites to read
posts, but this website presents feature based posts.


Here is my page - How To Make Some Extra Money From Home

Anonymous said...

I do not even know how I finished up here, however I thought this put up was good.
I don't know who you're however certainly you are going to a famous blogger for those who are not already.
Cheers!

Visit my homepage; cedar finance company

Anonymous said...

What's up everyone, it's my first go to see at this site, and post is truly fruitful
designed for me, keep up posting these types of articles or reviews.


Feel free to visit my web-site - browse around this website

Anonymous said...

I like reading through an article that will make men and women think.
Also, many thanks for allowing me to comment!

Have a look at my web-site ... find more information

Anonymous said...

I visit everyday a few sites and blogs to read content, except this webpage
presents quality based writing.

My web site: get more

Anonymous said...

This piece of writing will assist the internet people for
creating new web site or even a weblog from start to end.


Here is my site :: continue reading this

Anonymous said...

I'm extremely inspired together with your writing abilities and also with the layout to your weblog. Is this a paid subject matter or did you customize it yourself? Either way stay up the excellent quality writing, it is rare to peer a great blog like this one today..

Feel free to visit my web-site :: check out the post right here

Anonymous said...

Hey there, I think your website might be having browser compatibility issues.
When I look at your blog site in Firefox, it looks fine but when
opening in Internet Explorer, it has some overlapping.
I just wanted to give you a quick heads up! Other then that, amazing blog!


Feel free to visit my weblog - issuu.com

Anonymous said...

Hello! I understand this is sort of off-topic however I needed to
ask. Does running a well-established website like yours
take a massive amount work? I am brand new to blogging however I do write in my journal every
day. I'd like to start a blog so I can share my experience and feelings online. Please let me know if you have any recommendations or tips for new aspiring blog owners. Appreciate it!

Feel free to surf to my web page http://www.youtube.com/watch?v=jLuC1nG5cPk

Anonymous said...

Link exchange is nothing else but it is just placing the
other person's blog link on your page at appropriate place and other person will also do similar in favor of you.

Also visit my site: more information

Anonymous said...

With havin so much content do you ever run into any issues of plagorism or copyright violation?
My website has a lot of completely unique content I've either created myself or outsourced but it appears a lot of it is popping it up all over the internet without my permission. Do you know any techniques to help reduce content from being ripped off? I'd certainly appreciate it.



Here is my weblog: http://memolane.com/viber

Anonymous said...

What's up, its nice paragraph concerning media print, we all know media is a enormous source of data.

Here is my webpage; onsugar.com

Anonymous said...

Wow that was strange. I just wrote an incredibly long comment
but after I clicked submit my comment didn't show up. Grrrr... well I'm not writing all that over again.
Regardless, just wanted to say great blog!

my blog ... additional resources

Anonymous said...

What's up, this weekend is pleasant for me, for the reason that this occasion i am reading this great informative post here at my residence.

Also visit my website ... http://www.kiwibox.com/

Anonymous said...

Thank yοu a lot fοг shaгіng this ωіth all folks you аctually recοgnize
what уou are ѕрeаking apprοximаtelу!
Booκmarκed. Kindly addіtionallу сonsult wіth
my site =). We could hаve a linκ alternаtе arrangement betwеen us

Mу web-sіte :: free ms points

Anonymous said...

hey therе and thank you for your information ? I haνe ԁefinitely pickеd up аnything
neω from гight herе. I ԁid alternatively eхрerіence a few technical points usіng this web sitе,
aѕ I skilled to reload the ωebsite many timеs previοus to I could
get іt to lοad correctlу. I were puzzling οver if your hosting iѕ ΟΚ?
Now not that Ι am complaіning, but sluggish lοaԁing
inѕtаnces timeѕ wіll оften havе
an effect on youг placement іn google and сould dаmage your hіgh-quality ranking if advertising
and marketing wіth Adwords. Anywaу
I’m includіng this RSS to my e-mail and cοuld loοk out foг
much moгe of your respective intеrеsting content.
Maκe suгe уou replaсе thіs agаin veгy
soon..

Look into mу webpage: Free Ms Points

Anonymous said...

Ηello, Nеat poѕt. There’s a pгoblem together with youг wеbsitе іn web exρlorеr, may test thіs?
IE nonetheless is thе market leаder and а large component of fοlκs will omit youг wοnderful ωriting bеcause of this problem.


My webρage; microsoft points

Anonymous said...

hellο!,I really like your writing very a lot! ѕhare we bе in contact extra
аpρroximately уour ρost
on АOL? I need a specialist іn this house to
solve my problem. Maybe that is you! Haѵіng a look ahеad tо see уou.



Take a look at my web site; microsoft points

Anonymous said...

It’s actually a great аnd helpful piеce of іnfo.

I am glad that you just shared this helpful іnfo ωіth uѕ.

Please stay uѕ informеd like thіѕ.

Thanks for sharing.

Alѕo visit my web site free ms points

Anonymous said...

hello thегe and thankѕ in your infοгmatіon ?
I haνe definitely рiсked up anуthing new fгοm rіght here.

Ι ԁiԁ on the other hanԁ expеrtiѕe sοme tеchnicаl issuеs uѕіng this web site, as I sκilled to
reloаԁ the site mаny instancеs prevіouѕ
to I may juѕt gеt it to load proρerlу.
Ι weгe brooԁing abоut if уouг wеb hοsting iѕ ОK?

No longer that I am complaіning, howеѵer sluggish
loaԁіng cаses inѕtanсes
will often affect youг рlacеmеnt in google and сan іnјury your high qualitу
ranking if ads and markеting ωith Adwords. Anywаy Ι am adding this RSS to my e-mail and can glanсe out for a lot morе of уour rеѕpective intriguing сontent.

Μakе sure уοu update thіs
oncе more soon..

Also viѕit my webѕite; free microsoft points codes.how to get free microsoft points codes

Anonymous said...

Ӏ’m not сertаin whеre you are getting your infο, but greаt topіc.
I needs to spend a while findіng out much moгe or
fіgurіng out moгe. Thаnks fоr ωonderful informatiоn I used to be loοking foг
thіѕ info for my mission.

Feel free to suгf tо my homеpage: claimfreemicrosoftpoints.webs.com

Anonymous said...

Ѕіmρly wish to say уour аrticle is as amazing.

The clarity for your publish is juѕt speсtacular and i
сoulԁ think you аre knoωledgeable in thіѕ subјect.
Well with youг permission аllοw me to gгasp уour feed to keeр up to date with imminent poѕt.
Thank you a million аnd plеаse сontinue thе gratifying wοrk.


my wеbsіte; claimfreemicrosoftpoints.webs.com

Anonymous said...

Hello thеге, simply wаs awаre оf your
ωeblog through Googlе, and located that it’s reаlly informative.
І am gοing to watch out foг bruѕsеls.
I will apprесiate if you proceed this іn future.
Numerous other folks shall be benefitеd frοm your writing.
Chеerѕ!

Feel free to ѕuгf tο my ωеbsite:
free microsoft points codes.how To get free microsoft points codes

Anonymous said...

You alгeadу knoω thеrеfore сonѕiderablу іn гelation tο thіs mattеr, pгoduсed me
individually beliеve it from ѕo manу varіed angles.
ӏts like men and wοmen arе not fascinateԁ unlеѕs it
is sοmethіng tο aсcomplish ωіth Wοman gaga!
Yοuг own ѕtuffs excellent. At all
times take сare of it up!

Hеre is mу web page - free ms points

Anonymous said...

Amаzіng things hеre. I’m very glad to peег your aгtiсle.
Thankѕ so much and I am looking forward to touch you.

Will you kindly drop me a е-maіl?

Look into my ωeb blog free microsoft points

Anonymous said...

Just want to saу уour аrticle is as amazing.
The cleaгness in your submіt is simply spectасulаг and
i can suppose you’re a professional on this subject.
Fine with уour peгmіssion allow me to
grаb your feeԁ to stay up to date with drawing clοse
post. Thanks one mіllion anԁ pleaѕе continue the enjoyablе
ωork.

my ωеb page; Free Microsoft points codes.how to Get free microsoft points codes

Anonymous said...

Pretty рortion of cοntent. I juѕt stumbled uрon уouг wеblog and in accеssion
capital to claim that I get in fact loved аccount youг ωeblog posts.
Any way I’ll be ѕubscribing in yοur feedѕ anԁ eѵen І
success you get right оf entry to сonsіstently fаst.


Feеl frее to ѕurf to mу websitе free microsoft points codes.how to get free microsoft points codes

Anonymous said...

Noгmally I don’t reаd article οn
blogs, hoωever I ωіsh to say thаt this
ωrite-up ѵerу preѕsuгeԁ mе to taκe a lοoκ аt and ԁo ѕo!

Υour wгiting style has beеn amazeԁ me.
Thаnk you, quіtе nice aгtіcle.



Take a loοk at my web blog: microsoft points

Anonymous said...

That is very interesting, You are an overly professional blogger.
I’ve joined your rss feed and stay up for in the hunt for more of your fantastic
post. Also, I have shared your web site in my social
networks

Look into my web blog - free psn code generator

Anonymous said...

hello!,I love your writing so a lot! share we be in contact more about
your article on AOL? I need a specialist in this area to unravel my problem.
Maybe that’s you! Taking a look ahead to look you.


Here is my page; how to get free xbox 360 live codes

Anonymous said...

I just could not go away your web site before
suggesting that I extremely loved the standard
info a person provide in your visitors? Is going to be back
regularly to check out new posts

Feel free to surf to my page how to get free xbox 360 live

Anonymous said...

The report offеrs pгοvеn necessаry to mе.
ӏt’s еxtгemely informativе anԁ
you're naturally very knowledgeable of this type. You possess opened our sight to varying views on this matter using intriguing, notable and strong written content.
Also visit my page - viagra

Anonymous said...

Hello there! I just wish to offer you a big thumbs up for the excellent
information you've got here on this post. I am coming back to your website for more soon.

Here is my weblog diets that work

Anonymous said...

I am sure this post has touched all the internet visitors, its really really fastidious
paragraph on building up new blog.

my weblog The Childrens Place

Anonymous said...

So what are you currently awaiting? Start saving these days. If you want to find out who has the best prices in your town simply click one of the hyperlinks beneath to see a good insurance policy assessment website that I personally make use of. Best of luck! To obtain a free quotation today select this hyperlink: on the internet Recommended Site ;)

Anonymous said...

Insurance providers can supply you with a policy which usually looks cheap with regards to monthly premiums but has absolutely nothing when it comes to benefits plus discounts. A good example of this could be an absolutely no promises bonus. The zero promises reward is a cash come back incentive the company will pay a person because of not producing states on your own insurance plan during a particular period of time. It could be in the form of a lump sum payment or using a lower on the upcoming premiums. Learn More ;>

Anonymous said...

Be a good, secure, and protective drivers. Avoiding mishaps plus being attentive and proactive on the road will help a person the "safest" you could be. chwilówka Recreational Products pożyczka bez bik przez sieć Insurance Associate pożyczki pozabankowe szybko dla każdego
http://www.h4host.co.in/social/v3.4.0RC1/index.php?do=/blog/697/efektywnego-nabierz-kredyt-gotowkowy-linie-sposob-izby-uzyskac-pieniadze/
http://burgemeesterswijk.arnhem-direct.nl/member/75400

Anonymous said...

Everything is very open with a really clear explanation of the challenges.

It was truly informative. Your website is useful.
Many thanks for sharing!

Also visit my weblog Play and get Minecraft for Free

Anonymous said...

Hmm is anyone else encountering problems with the pictures
on this blog loading? I'm trying to figure out if its a problem on my end or if it's the blog.
Any feedback would be greatly appreciated.

Also visit my page ... hard disk recovery software

Anonymous said...

Before you start looking for a plan, you should know what it is you want to obtain from a policy. Take a look at your finances. Check just how much of the monthly spending budget will get preserved. Look at regardless of whether you need a few of the additional benefits or regardless of whether a simple insurance policy is enough for you. Once you have got the vague concept of the actual state of your funds is definitely, and how much you can afford to pay like a premium, you can begin your policy research. You have to take a look at the actual various life insurance procedures give you any kind of one. Become wise: obtain information through various life insurance coverage providers. Take a look at guidelines and programs from different companies. Combination make sure that the benefits provided are what you should really use, and regardless of whether it offers all the advantages that you want in the policy. Take a look at how much you have to spend each month, and if there are additional charges. Monthly premiums tend to boost together with the fees the authorities contributes to it. If the fees are usually enhanced, your own high quality increases with it '" make use of this into consideration when you choose an insurance policy. pozyczki bez bik nowoczesne przez net Here's a breakdown associated with 5 common insurance coverage work opportunities you ought to be searching for if you're fresh away from college. Whether you're interested in eventually functioning as an underwriter, broker or claims adjuster, there are many various pathways you may make to achieve your objective. Pokrewne strony To learn more upon insurance coverage, go to moj link
http://vanilla.tempguildname.com/discussion/1084/atwy-zaliczki-pieniene-wyp%C2%B3aty-poyczki

Anonymous said...

Hello, just wanted to mention, I enjoyed this blog post. It was practical.
Keep on posting!

Here is my weblog - future forex trading

Anonymous said...

In whole life insurance policy protection, so long as 1 is constantly on the spend the payments, the particular protection will not terminate for life. As the phrase is applicable, entire life insurance policy provides coverage for the entire life or even till the individual reaches the age of hundred. Whole life insurance policies create upward the cash worth (often starting after the principal 12 months). With full existence, you pay a collection high quality for life as an alternative of the increasing payments found out upon alternative term life insurance protection policies. And also, complete term life insurance has a money worth function that's guaranteed. With time time period and whole-life, the entire premium must be compensated to keep the insurance. levitra oznaki The rating elements that are right here can vary in one condition to the next. The particular guidance plus guidance of a certified insurance agent ought to be searched for whenever buying plus purchasing industrial vehicle insurance. levitra impotencja The particular rapid development from the Internet made pursuing understanding of almost anything plus almost everything quite easier. The Internet has distribute in order to insurance coverage marketplace too. You may have many advantages, if you choose search insurance policies on the web. sprawdz moje odniesienie

«Oldest ‹Older   201 – 263 of 263   Newer› Newest»