Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 嵌套在div中的命名span类的CSS语法是什么?_Html_Css - Fatal编程技术网

Html 嵌套在div中的命名span类的CSS语法是什么?

Html 嵌套在div中的命名span类的CSS语法是什么?,html,css,Html,Css,在下面,我如何引用“name”类 名称 地址 应该有用。简单 <style> .name { } </style> 有更多的选择方法,但你能抓住要点。div.resultDetails>span.name在大多数浏览器中都能使用 但是,它在IE6中不起作用。如果这是一个问题,只需使用: div.resultDetails span.name{}应该正确地以span为目标(前提是在div中没有任何嵌套的span.name元素,而您不打算以这些元素为目标) div。。

在下面,我如何引用“name”类


名称
地址
应该有用。

简单

<style>
.name
{

}
</style>

有更多的选择方法,但你能抓住要点。

div.resultDetails>span.name在大多数浏览器中都能使用

但是,它在IE6中不起作用。如果这是一个问题,只需使用: div.resultDetails span.name{}应该正确地以span为目标(前提是在div中没有任何嵌套的span.name元素,而您不打算以这些元素为目标)

div
。。告诉元素类型

然后是空格
span
。。指示查看子级别中的跨度元素


.name
。。告诉我们看看那些css类名为
name

的元素,我想说的是,除非您希望这些样式只应用于div标记,否则不应该在那里使用
div
。。。。坚持使用不带标记的CSS选择器可以减少样式表的文件大小,因此这是一个很好的做法。@webnet:OP特别说明了如何获取span标记,所以我想要显式路由。不过,我确实倾向于同意你的看法。我认为这是离题的。也许他需要一个通用的aproch,也许他想为这个div和span的特定组合设定一种风格。正如你从可用的回答中所看到的,你真的需要弄清楚这里是否有任何限制因素。您是否只需要
name
span
上显示?仅在
resultDetails
中?仅直接在
div
s之后?
div.resultDetails > span.name { ... }
<style>
.name
{

}
</style>
div span.name // selects all spans with class "name" in any div
div > span.name // this one selects only the spans that are direct children of a div
div.resultDetails span.name //select only spans with class "name" in only divs with class="result Details
.resultDetails .name // selects any element with class "name" in any element with class "resultDetails" 
div span.name { ... }