I’ve created a <ul> menu for my navigation and now I want to add another <ul> for bullet points but the <ul> bullet points are picking up the styles of the <ul> nav. I’ve tried giving the nav <ul> a style but it’s still not working?
It’s best to give the nav ul a class of its own, which you can then use to apply any styles that are unique to that element. At the moment, the nav styles are applied to all ULs, which is not what you want.
What you need to realize is that CSS declarations cascade
so a rule like UL LI {} affect ALL LIs within the first UL , not just the children. ( btw giving a class to each LI would work too, but it’s a bit heavy handed).
you can RESET the lower level elements like this .nav LI LI{ lower level rules…}
or
You can use the child selector UL.nav>LI { top level rules }
So these would be the 2 different classes applied below?
CLASS ONE
.class_one ul {
/* CSS here */
}
.class_one ul li {
/* CSS here */
}
.class_one ul li:hover {
/* CSS here */
}
.class_one ul li ul {
/* CSS here */
}
.class_one ul li ul li {
/* CSS here */
}
.class_one ul li ul li:hover {
/* CSS here */
}
.class_one ul li:hover ul {
/* CSS here */
}
Yes, except that you’ve made a mistake. If you have this in your HTML:
<ul class="class_one">
then you target it like this:
ul.class_one {
/* CSS here */
}
That targets a UL with a class of “class_one”. The way you were writing it, the class would have to be on a parent of the UL, rather than on the UL itself. So you need to change each example above.
Again I am having an issue with classes [ I think ] I have an anchor at the bottom of the page which is a CSS image rollover - http://rossnaumov.com.au/clients/PPC/
I am trying to use the same CSS image rollover effect for the menu but when I do it moves the coffee image outside of the menu div. I’m thinking it must be a class issue?
FYI: That string of code background: url("images/coffee.png") repeat scroll center bottom transparent;
was displayed by Firebug. Firebug includes the default properties that are being applied by the shorthand in addition to those that you have applied in your CSS. The significant part of my post was the added properties in blue.