CSS3过渡:有没有使用JQuery点击选项? [英] CSS3 Transitions: is there an on click option without using JQuery?
本文介绍了CSS3过渡:有没有使用JQuery点击选项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这很棒:
<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>
但是有没有人知道如何使用click而不是hover?不涉及JQuery?
But does anyone know of a way to do this using click instead of hover? And not involving 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>
请检查此 http: //jsfiddle.net/nMNJE/
这篇关于CSS3过渡:有没有使用JQuery点击选项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文