在ASP.Net CSS + CSS语法问题类之间的差值Vs的CssClass [英] Difference between Class vs CSSClass in ASP.Net CSS + CSS syntax question

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

问题描述

之间有什么区别:

<asp:GridView CssClass="someclass"

<table class="someclass">

和它是如何涉及到如何定义CSS?
例如,使用的CssClass,人们可以(我认为)写像这样的CSS:

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;}

但是,使用类,看来这个语法不起作用,并从<一个判断href=\"http://www.w3.org/TR/css3-selectors/#class-html\">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之间的差异?

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?

好吧,看起来他们是同样的事情....所以,是上述两种语法正确使用类或的CssClass的时候,因为他们似乎并不如此。

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是围绕CSS类说明一个抽象的包装。

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

从本质上讲,对于大多数的意图和目的,它们是相同的东西。当你在的CssClass 属性设置为像SomeClass的,即WebControl的将呈现将是HTML一些字符串类=SomeClass的

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".


编辑:你写的CSS选择器都是正确的,但他们做的是两回事。 .someclass日匹配任何的后代​​的第一个具有SomeClass的类元素的元素。第二个具有SomeClass的类个元素本身相匹配。

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.

希望是十分明显的。不管你的方式指定的元素(使用ASP.Net的CssClass属性,或者只是设置类)类,你的CSS选择器会做同样的事情。他们没有什么做与ASP.Net明确。

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语法问题类之间的差值Vs的CssClass的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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