如何使用CSS或jQuery动画元素的“不透明度”?
答案 0 :(得分:2)
当然,使用CSS转换:
div {
opacity: 1;
-moz-transition: all 0.3s ease-out; /* FF4+ */
-o-transition: all 0.3s ease-out; /* Opera 10.5+ */
-webkit-transition: all 0.3s ease-out; /* Safari 3.2+, Chrome */
-ms-transition: all 0.3s ease-out; /* IE10+ */
transition: all 0.3s ease-out; /* standard format */
}
div:hover {
opacity: 0.3;
}
<div>Hover over me with your mouse!</div>
<div>Hover over me with your mouse!</div>
<div>Hover over me with your mouse!</div>
<div>Hover over me with your mouse!</div>
<div>Hover over me with your mouse!</div>
<div>Hover over me with your mouse!</div>
答案 1 :(得分:1)
CSS3过渡可以做到这一点。我正在为鼠标激活的工具栏执行以下操作:
CSS
<style type="text/css">
#cmsToolBar {
font-family: helvetica,arial,sans-serif;
font-size: 1.1em;
padding: 5px;
line-height: 1.5;
min-height: 1em;
width: 100%;
position: fixed;
top: 0;
left: 0;
color: black;
background-color: #DDDDBB;
opacity: 0.15;
border-bottom: dotted 1px black;
transition-duration: .2s;
-moz-transition-duration: .2s;
-webkit-transition-duration: .2s;
-o-transition-duration: .2s;
}
#cmsToolBar:hover {
min-height: 5em;
opacity: .98;
}
</style>
HTML
<div id="cmsToolBar">
<p>This is where the CMS tool bar will go</p>
</div>
答案 2 :(得分:0)
没有。您需要使用.fadeIn('slow or fast')
或.fadeOut('slow or fast')