I am jsut wondering why the CssClass="blah" is not avaliable inside my div tags when style="blah" 开发者_C百科works.
Is this not part of CSS? Is there a way to set this up? Can I give...
<div class="foo">
</div>
and set the inline css to...
#div foo{blah}
or something like that?
Thanks in advance.
You add the class to you div correctly:
<div class="foo">
</div>
But in your CSS, you are using the id identifier (#) instead of the class identifier (.):
/* This would match any <foo> element with a parent that has an id of div
for example <span id="div"><foo>...</foo></span> */
#div foo{blah}
/* This matches <div class="foo"> */
div.foo { blah }
Yes. You can absolutely do that. CssClass
is a asp.net server-side controls (only) property. It translates to html's standard attribute class
when rendered to the browser.
CssClass is a .net server side property. You would need to set ruant="server"
on the <div>
tag to use this. Or you can just use class="foo"
like you have.
<div runat="server" CssClass="foo">
</div>
First CssClass is a .NET construct only. HTML does not know anything about CssClass. A element can only have a class="foo foo1 foo2" value assigned to it. As for for your CSS selector you need to switch it to:
div#foo { border: 1px solid gray; }
I wouldn't really consider it "inline css" as that usually refers to a situation like this:
<div style="border: 1px solid gray; background-color: white;">My Div Content</div>
Here is a list of all the attributes and events a div element can contain:
http://www.w3schools.com/tags/tag_div.asp
精彩评论