Forum OpenACS Q&A: css question

Collapse
Posted by Jonathan Ellis on
if i have <div class=asdf>foo</div>, and i want part of "foo" to be another div with regular body style, can i do that w/o making a "clone" of BODY in the css? (<div class=body> doesn't work.)
Collapse
2: Re: css question (response to 1)
Posted by Bruno Mattarollo on

Hello Jonathan,

I don't think you can make class=body since body is a tag in the HTML and not a class in CSS (.body in the CSS). I don't think you can do what you want without having a special class for that particular div.

My 2 cents.

/B

Collapse
3: Re: css question (response to 1)
Posted by Steve Manning on
You can place another <div> tag without a class which would pick up the default -

<div class=asdf>hello</div>
<div>small</div>
<div class=asdf>world</div>

but I don't think you can nest the <div>'s if thats what you mean  -

<div class=asdf>
hello
<div>small</div>
world
</div>

My thruppence ha'penny ;)

    - Steve

Collapse
4: Re: css question (response to 1)
Posted by Torben Brosten on
DIVs are block level tags that can be nested.

Try assigning a class to BODY, and using the same class with the nested DIV.

If it doesn't  work, there may be some precedence in the other class attributes that remain more significant. You may need to use:

!important ;

to override. Also, check syntax on the rest of the page, as "faulty" syntax can cause interpretation breaks.

cheers,
Torben

Collapse
5: Re: css question (response to 1)
Posted by Sean Redmond on

The short answer is "no". But how you do it depends on your stylesheet. In the first place you're talking about a contextual selector div.asdf div (i.e. a div with no class inside a div with a class of asdf). You could save yourself some "cloning" by combining the definitions of body and div.asdf div, but you'll have to explicitly spell out what would otherwise be defaults:

body, div.asdf div {
    font-style: normal;
    font-weight: normal;
    font-size:medium;
}

div.asdf {
    font-style: italic;
    font-weight: bold;
    font-size: large;
}

Collapse
6: Re: css question (response to 1)
Posted by Jonathan Ellis on
Thanks for the answers.