Forum Moderators: not2easy
First of all, let me apologies for what may be a dumb question - I've got very little CSS experience.
I'm using a expandable list menu (from dynamic drive), which has roughly the following structure:
<UL>
<LI>Main Menu</LI>
<UL>
<LI>Sub Menu 1</LI>
<LI>Sub Menu 2</LI>
</UL>
</UL>
I want to put a background color on the Main Menu item (so in a big list, it shows up as a heading). However, when i put a background-color style tag on it, it also includes the sub menus in the UL.
Ideally, I would like a background color that stretches the width of the page, or even some kind of image background (but, something that will handle cross-browser, and different resolutions).
Any help would be appreciated.
ul li {
background: red /* this sets the first level li */
}
ul li ul li {
background: #fff /* this sets the second level li */
}
Thanks for the quick reply.
The only problem with that solution is that i then get a 'box inside a box', with the background color of the UL around the color of the LI's.
If you try out the following, you can see that the highlight covers the bullets in the child list.
<UL>
<LI style='background-color: #e7e7e7'>Main Menu</LI>
<UL style='background-color: #7e7e7e'>
<LI>Sub Menu 1</LI>
<LI>Sub Menu 1</LI>
</UL>
</UL>
I want the background to cover the main menu, including the bullet.
Just noticed that it does work in firefox, but it doesn't in IE...
Damn IE...
Ahh, yes, had missed that. UL now moved.
The list-style-position property seems to move the bullets inside the block of color, but still keeps the outside block of color.
<UL>
<LI style='background-color: #e7e7e7'>Main Menu
<UL style='background-color: #7e7e7e;list-style-position: inside;'>
<LI style="list-style-position: inside;">Sub Menu 1</LI>
<LI style="list-style-position: inside;">Sub Menu 1</LI>
</UL>
</LI>
</UL>
Any other ideas?
Any other ideas?
That works! Thanks for your help.
Cheers,
Matt