Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/35.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
CSS:last of type和:before不起作用_Css - Fatal编程技术网

CSS:last of type和:before不起作用

CSS:last of type和:before不起作用,css,Css,我在应用:类型的最后一个和:之前时遇到问题 我有以下资料: .stepwizard-row:before { position: absolute; top: 0px; content: " "; width: 1px; height: 100%; background-color: #97D3FD; } .stepwizard-row:before:last-of-type { position: absolute; top: 0px; content: "

我在应用
:类型的最后一个
:之前
时遇到问题

我有以下资料:

.stepwizard-row:before {
  position: absolute;
  top: 0px;
  content: " ";
  width: 1px;
  height: 100%;
  background-color: #97D3FD;
}
.stepwizard-row:before:last-of-type {
  position: absolute;
  top: 0px;
  content: " ";
}
但是,类型的
:before:last似乎没有任何效果


我做错了什么?

您的订单错了,应该是:

.stepwizard-row:last-of-type:before {}

每个选择器只能出现一个伪元素,如果存在,它必须出现在表示选择器主题的简单选择器序列之后。注意:本规范的未来版本可能允许每个选择器使用多个伪元素

顺便说一句,使用
.class:last of type
可能会出现意外行为,它确实应该与元素一起工作,例如
.parent>div:last of type

相同:类型(1)的第n个最后一个
:type的last
伪类表示一个元素,该元素在其父元素的子元素列表中是其类型的最后一个同级元素


您的订单有误,应该是:

.stepwizard-row:last-of-type:before {}

每个选择器只能出现一个伪元素,如果存在,它必须出现在表示选择器主题的简单选择器序列之后。注意:本规范的未来版本可能允许每个选择器使用多个伪元素

顺便说一句,使用
.class:last of type
可能会出现意外行为,它确实应该与元素一起工作,例如
.parent>div:last of type

相同:类型(1)的第n个最后一个
:type的last
伪类表示一个元素,该元素在其父元素的子元素列表中是其类型的最后一个同级元素


请发布一个.From Spec-每个选择器只能出现一个伪元素,如果存在,它必须出现在表示选择器主题的简单选择器序列之后。@Harry
::before
是一个伪元素,但
:last of type
是一个伪类。有可能使用吗both@blonfu:请检查突出显示的部分:)请发布一个。来自规范-每个选择器只能显示一个伪元素,如果存在,它必须出现在表示选择器主题的简单选择器序列之后。@Harry
::before
是一个伪元素,但
:last of type
是一个伪类。有可能使用吗both@blonfu:请检查突出显示的部分:)