From: BootNic on
On Wed, 21 Jul 2010 08:18:01 -0400
Jeff Thies <jeff_thies(a)att.net> wrote:

> My goal is fewer templates and just one stylesheet per site.
>
> To get there I usually add an id in the body tag.
>
> <body id=“body_id” ...
>
> Then if I want to change the side_nav it is just:
>
> #body_id #side_nav{...
>
> That works well but I find that sometimes I’ll need a small
> styling bit on just one page, what I’d like to do is add a class (I
> can do that in the CMS) so I can write a new set of rules with a
> higher specifity.
>
> <body id=“body_id” class=“new_class” ....
>
> How do I write the rule so it has a higher “score”, just doing
> this:
>
> .new_class #side_nav is lower than #body_id #side_nav

#body_id .new_class #side_nav

[snip]


--
BootNic Wed Jul 21, 2010 12:35 pm
"I've noticed that the press tends to be quite accurate, except when
they're writing on a subject I know something about."
*Keith F. Lynch*
From: BootNic on
On Wed, 21 Jul 2010 12:35:22 -0400
BootNic <bootnic.bounce(a)gmail.com> wrote:

> On Wed, 21 Jul 2010 08:18:01 -0400
> Jeff Thies <jeff_thies(a)att.net> wrote:
>
> > My goal is fewer templates and just one stylesheet per site.
> >
> > To get there I usually add an id in the body tag.
> >
> > <body id=“body_id” ...
> >
> > Then if I want to change the side_nav it is just:
> >
> > #body_id #side_nav{...
> >
> > That works well but I find that sometimes I’ll need a small
> > styling bit on just one page, what I’d like to do is add a class (I
> > can do that in the CMS) so I can write a new set of rules with a
> > higher specifity.
> >
> > <body id=“body_id” class=“new_class” ...
> >
> > How do I write the rule so it has a higher “score”, just doing
> > this:
> >
> > .new_class #side_nav is lower than #body_id #side_nav
>
> #body_id .new_class #side_nav

There should be no space after #body_id

#body_id.new_class #side_nav

--
BootNic Wed Jul 21, 2010 12:38 pm
It is well known that "problem avoidance" is an important part of
problem solving. Instead of solving the problem you go upstream and
alter the system so that the problem does not occur in the first
place.
*Edward de Bono*
From: Jeff Thies on
BootNic wrote:
> On Wed, 21 Jul 2010 12:35:22 -0400
> BootNic <bootnic.bounce(a)gmail.com> wrote:
>
>> On Wed, 21 Jul 2010 08:18:01 -0400
>> Jeff Thies <jeff_thies(a)att.net> wrote:
>>
>>> My goal is fewer templates and just one stylesheet per site.
>>>
>>> To get there I usually add an id in the body tag.
>>>
>>> <body id=“body_id” ...
>>>
>>> Then if I want to change the side_nav it is just:
>>>
>>> #body_id #side_nav{...
>>>
>>> That works well but I find that sometimes I'll need a small
>>> styling bit on just one page, what I'd like to do is add a class (I
>>> can do that in the CMS) so I can write a new set of rules with a
>>> higher specifity.
>>>
>>> <body id=“body_id” class=“new_class” ...
>>>
>>> How do I write the rule so it has a higher “score”, just doing
>>> this:
>>>
>>> .new_class #side_nav is lower than #body_id #side_nav
>> #body_id .new_class #side_nav
>
> There should be no space after #body_id
>
> #body_id.new_class #side_nav

Thanks, that's what I missed!

(if that is in the CSS specs I couldn't find it)

Jeff
>
From: Beauregard T. Shagnasty on
BootNic wrote:

> Jeff Thies wrote:
>>
>> <body id=�body_id� ...
>> ...

Hey BootNic, are you aware your reader is changing quoted standard
quotemarks to those smartquote thingies?

In raw, I see in your post:
> <body id=3D=E2=80=9Cbody_id=E2=80=9D ...
but Jeff's is plain old ".

--
-bts
-Four wheels carry the body; two wheels move the soul
From: David Stone on
In article <i279od$vsn$1(a)news.albasani.net>,
Jeff Thies <jeff_thies(a)att.net> wrote:

> BootNic wrote:
> > On Wed, 21 Jul 2010 12:35:22 -0400
> > BootNic <bootnic.bounce(a)gmail.com> wrote:
> >
> >> On Wed, 21 Jul 2010 08:18:01 -0400
> >> Jeff Thies <jeff_thies(a)att.net> wrote:
[snip]
> >>> <body id=“body_id” class=“new_class” ...
> >>>
> >>> How do I write the rule so it has a higher “score”, just doing
> >>> this:
> >>>
> >>> .new_class #side_nav is lower than #body_id #side_nav
> >> #body_id .new_class #side_nav
> >
> > There should be no space after #body_id
> >
> > #body_id.new_class #side_nav
>
> Thanks, that's what I missed!
>
> (if that is in the CSS specs I couldn't find it)

It's easier to find once you know what to look for!

In http://www.w3.org/TR/CSS21/selector.html#descendant-selectors
[quote]
A descendant selector is made up of two or more selectors separated by
white space. A descendant selector of the form "A B" matches when an
element B is an arbitrary descendant of some ancestor element A.
[/quote]

And...

In http://www.w3.org/TR/CSS21/selector.html#class-html
[quote]
To match a subset of "class" values, each value must be preceded
by a ".". Example(s):
For example, the following rule matches any P element whose "class"
attribute has been assigned a list of space-separated values that
includes "pastoral" and "marine":
p.marine.pastoral { color: green }
[/quote]

In your case, writing #body_id .new_class means selecting for
something of class new_class which is a descendant of the
element with id body_id, rather than selecting an element
whose id is body_id and which also is of the class new_class
First  |  Prev  |  Next  |  Last
Pages: 1 2 3 4
Prev: ping Dorayme
Next: Most important for mobile stylesheet?