fai*_*jua 13 html css css3 css-transitions
寻找线索,如何在过渡时使用背景颜色的不透明度?
我正在使用rgba()功能,但转换不适用于悬停.
.bx{
background:rgba(255,0,0,0.5);
width:100px; height:100px;
position:relative;
transition: opacity .5s ease-out;
-moz-transition: opacity .5s ease-out;
-webkit-transition: opacity .5s ease-out;
-o-transition: opacity .5s ease-out;
}
.bx:hover{
background:rgba(255,0,0,1);
}
.t{
position:absolute;
bottom:0px;
}
Run Code Online (Sandbox Code Playgroud)
HTML
<div class="bx"><div class="t">text</div></div>
Run Code Online (Sandbox Code Playgroud)
任何想法,我如何使用转换.bx?
Has*_*ami 22
事实上,opacity并且rgba()完全不同.
由于您使用属性rgba()作为背景颜色,因此background您需要使用background如下的过渡属性:
.bx {
background: rgba(255,0,0,0.5);
width:100px; height:100px;
position: relative;
-webkit-transition: background .5s ease-out;
-moz-transition: background .5s ease-out;
-o-transition: background .5s ease-out;
transition: background .5s ease-out;
}
.bx:hover {
background: rgba(255,0,0,1);
}
Run Code Online (Sandbox Code Playgroud)