ASP.NET CSS + CSS语法问题中类与CSSClass之间的差异 [英] Difference between Class vs CSSClass in ASP.Net CSS + CSS syntax question

查看:200
本文介绍了ASP.NET CSS + CSS语法问题中类与CSSClass之间的差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

之间的区别:

 < asp:GridView CssClass =someclass

 < table class =someclass> 

它与如何定义CSS有什么关系?
例如,使用CssClass,我可以这样写CSS:

  .someclass {font-家庭: 
background-color:#FFFFFF;
width:100%;
font-size:small;}
.someclass th {background:#7AC142;
padding:5px;
font-size:small;}

但是使用类似乎这个语法doesn' t工作,并从 http://www.w3.org/TR / css3-selectors /#class-html 我必须这样写:

  .someclass { font-family:arial; 
background-color:#FFFFFF;
width:100%;
font-size:small;}
th.someclass {background:#7AC142;
padding:5px;
font-size:small;}

有人可以露出一些光,方法,或者如果它们都正确,但在ASP.Net中的类和CssClass之间有区别?



UPDATE



好吧,看起来他们是一样的东西....所以,上述语法都正确时使用类或cssclass,因为他们似乎不是。



基本上,对于大多数意图和目的,他们是同样的事情。当您将 CssClass 属性设置为像someclass这样的字符串时,WebControl将渲染的HTML将为 class =someclass






编辑:你写的CSS选择器都是正确的不同的东西。 .someclass th匹配具有someclass类的元素的任何后代 th元素。第二个匹配具有someclass类的第th个元素本身。



希望很清楚。无论你指定元素的类(使用ASP.Net的CSSClass,或只是设置类),你的CSS选择器将做同样的事情。他们与ASP.Net没有任何关系。


What is the difference between:

<asp:GridView CssClass="someclass"

and

<table class="someclass">

And how does it relate to how one defines CSS? For example, using CssClass, one can (I think) write CSS like so:

.someclass {font-family:"arial";  
        background-color:#FFFFFF;  
        width: 100%;  
        font-size: small;}  
.someclass th {background: #7AC142;  
             padding: 5px;  
            font-size:small;}

But using class, it seems this syntax doesn't work, and judging from http://www.w3.org/TR/css3-selectors/#class-html I would have to write the above like this:

.someclass {font-family:"arial";  
        background-color:#FFFFFF;  
        width: 100%;  
        font-size: small;}  
th.someclass {background: #7AC142;  
             padding: 5px;  
            font-size:small;}

Can someone shed some light on which is the correct way, or if they are both correct, but there is a difference between class and CssClass in ASP.Net?

UPDATE

Ok, looks like they are the same thing....so, are the above syntaxes both correct when using class or cssclass, because they don't seem to be.

解决方案

ASP.Net CssClass is an abstract wrapper around the css "class" specifier.

Essentially, for most intents and purposes, they are the same thing. When you set the CssClass property to some string like "someclass", the html that the WebControl will render will be class = "someclass".


EDIT: The CSS selectors you have written are both "correct", but they do two different things. ".someclass th" matches any descendant th element of an element that has the "someclass" class. The second one matches the th element itself that has the "someclass" class.

Hope that's clear. Regardless of the way you specify the class for the elements (using ASP.Net's CSSClass, or just setting the class), your CSS selectors will do the same thing. They don't have anything to do with ASP.Net specifically.

这篇关于ASP.NET CSS + CSS语法问题中类与CSSClass之间的差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆