效果很好:
<style type="text/css">
div
{
width:100px;
height:100px;
background:red;
transition:width 2s;
-moz-transition:width 2s; /* Firefox 4 */
-webkit-transition:width 2s; /* Safari and Chrome */
-o-transition:width 2s; /* Opera */
}
div:hover
{
width:300px;
}
</style>
但是有谁知道使用点击而不是悬停来做到这一点的方法吗?不涉及 JQuery?
谢谢!
最佳答案
你可以这样写:
CSS
input{display:none}
.ani
{
width:100px;
height:100px;
background:red;
transition:width 2s;
-moz-transition:width 2s; /* Firefox 4 */
-webkit-transition:width 2s; /* Safari and Chrome */
-o-transition:width 2s; /* Opera */
display:block;
}
input:checked + .ani{width:300px;}
HTML
<input type="checkbox" id="button">
<label class="ani" for="button"></label>
关于CSS3 过渡 : is there an on click option without using JQuery?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11166580/