WeLoveCSS Logo
Home Profile Members Search Rules Help New Posts



WeLoveCSS > WEB DESIGN > CSS > Parent UL styling on child UL

Reply
  Thread Tools Display Modes
Old 19th March 12, 09:14 PM   #1
ccdavies
WLC Member
 
Join Date: Jan 2011
Posts: 49
Default Parent UL styling on child UL

Hi. I have a UL within another UL. Both have ids and are styled differently. For some reason however, the child UL is using the parent UL's styling.

How can I ensure the child uses the correct styling?

Code:
<ul id="portfolio_show">
<li class="portfolio_thumb_1">
<li class="portfolio_thumb_2">
<li class="portfolio_thumb_3">
<li class="portfolio_thumb_1">
<li class="portfolio_thumb_2">
<ul id="pagination">
</ul>
Thank you
ccdavies is offline   Reply With Quote
Old 19th March 12, 09:43 PM   #2
chrishirst
Banned
 
Join Date: Jun 2006
Location: Blackp ool U.K.
Posts: 3,196
Default Re: Parent UL styling on child UL

A list cannot be a direct decendant of another UL it has to be a child of a list item.

And list items (</li>) HAVE to be closed!
chrishirst is offline   Reply With Quote
Old 19th March 12, 10:36 PM   #3
ccdavies
WLC Member
 
Join Date: Jan 2011
Posts: 49
Default Re: Parent UL styling on child UL

The code I copied in is from firebug, so of course the items are closed.

Thanks
ccdavies is offline   Reply With Quote
Old 20th March 12, 11:49 AM   #4
csswizard
WLC Member
 
Join Date: Mar 2012
Posts: 17
Default Re: Parent UL styling on child UL

It happens due to hierarchy. The best approach is to assign different values for the parent and the child property as per the need.

Suppose if you have assigned padding:10px to the parent then the child will also take 10px as padding automatically.

If you do not want the padding for the child then you have to assign padding:0px for the child.

I hope you can understand what i am trying to say
csswizard is offline   Reply With Quote
Old 20th March 12, 12:02 PM   #5
chrishirst
Banned
 
Join Date: Jun 2006
Location: Blackp ool U.K.
Posts: 3,196
Default Re: Parent UL styling on child UL

Quote:
Originally Posted by ccdavies View Post
The code I copied in is from firebug, so of course the items are closed.

Thanks
And we should know that because????

if you are providing code, paste it from the source code so we get the whole picture

That way it saves wasting your time and ours pointing to problems that don't actually exist, but obviously exist in what you provide.
It's a bit like taking your cat to the vets because your dog is not well.
chrishirst is offline   Reply With Quote
Old 20th March 12, 12:06 PM   #6
chrishirst
Banned
 
Join Date: Jun 2006
Location: Blackp ool U.K.
Posts: 3,196
Default Re: Parent UL styling on child UL

Anyway, Your ruleset for the child ul should be

Code:
ul#id li.class ul#id {
    // rules
}
that way the specificity of the ruleset will override the hierarchial rules.
chrishirst is offline   Reply With Quote
Reply


Thread Tools
Display Modes
Linear Mode Linear Mode

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

Forum Jump


All times are GMT. The time now is 02:16 PM.



Home | Advertise | Contact Us | Top
Home | Advertise | Contact Us | Top

Copyrightę 2006 WeLoveCSS.com. All Rights Reserved.
Powered by vBulletin Version 3.8.4 Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.