小编mas*_*iah的帖子

在不知道第一个孩子的类型的情况下选择第一个孩子

我有以下HTML代码:

<div class="foo">
   ...
   <span> ---> can be the first
   <h1> ---> can be the first
   <h2> ---> can be the first
   and so on...
   ...
</div> 
Run Code Online (Sandbox Code Playgroud)

我想在第一个元素中添加一些CSS样式,但不声明HTML元素的类型.

例如,这段代码对我没有帮助:

.foo span:first-child
Run Code Online (Sandbox Code Playgroud)

即使开发人员选择在div中进行更改,我也希望CSS能够在第一个元素上运行.

有什么办法吗?

html css css-selectors

5
推荐指数
1
解决办法
334
查看次数

css - 使转换仅适用于一种方式

我在css中有以下代码:

.item {
    opacity: 0;
    transition: opacity 1s linear;
    -webkit-transition: opacity 1s linear;
    -moz-transition: opacity 1s linear;
}

.item.seen {
    opacity: 1;
}
Run Code Online (Sandbox Code Playgroud)

当我将类添加seen到a时.item,opacity项目的转换从0变为1.

但是当我删除类seen.item所述opacity过渡(从1到0)也运行.

是否有任何方法可以在.seen添加时进行转换但不在删除时运行?

css css3

2
推荐指数
1
解决办法
5161
查看次数

标签 统计

css ×2

css-selectors ×1

css3 ×1

html ×1