我希望在进入和时离开变暗状态时会转换,但只有在离开时才会转换。如何在进入时进行过渡?我也试过了ease-in
和ease-out
,但这些似乎没有什么区别。
.is-dimmed-unless-active:not(:active):not(:focus):not(:hover) {
opacity: .5;
transition: opacity .5s ease-in-out;
}
的实例
答案 0 :(得分:3)
因为您需要在transition
上定义.card
:
.card {
transition: opacity .5s ease-in-out;
}
取而代之的是:
.is-dimmed-unless-active:not(:active):not(:focus):not(:hover) {
transition: opacity .5s ease-in-out;
}
答案 1 :(得分:0)
将你改为css:
.is-dimmed-unless-active {
transition: opacity .5s ease-in-out;
opacity: 1;
}
.is-dimmed-unless-active:hover {
opacity: .5;
}
.card {
width: 60%;
margin: 1em auto;
padding: 1em;
color: crimson;
border: 3px dotted crimson;
}
body {
font-family: sans-serif;
background: white;
}