在CSS3中完全展开/折叠
问题描述:
在我负责前端开发的日子里,我只能通过CSS和JavaScript实现展开/折叠行为。 已经可以在CSS3中完全编写一个展开/折叠解决方案吗?在CSS3中完全展开/折叠
编辑: 我打算做的是类似this,但这里它正在使用jQuery。
答
如从here借用和稍微调整:
/* Default State */
div {
background: green;
width: 400px;
height: 100px;
line-height: 100px;
color: white;
text-align: center;
display: none;
}
/* Toggled State */
input[type=checkbox]:checked ~ div {
display: block
}
高级展示与淡入这里:(编辑,并不需要如关键帧在评论中指出了!)http://jsfiddle.net/Dxvf7/2/
/* Default State */
div.container > div {
background: green;
width: 400px;
height: 100px;
line-height: 100px;
color: white;
text-align: center;
opacity: 0;
height: 0;
-webkit-transition: all 2s linear;
-moz-transition: all 2s linear;
-o-transition: all 2s linear;
transition: all 2s linear;
}
/* Toggled State */
div.container > input[type=checkbox]:checked ~ div {
opacity: 1;
height: auto;
}
你能悬停做到这一点,或单击只?如果只点击,这只能用CSS来完成。 – Mooseman 2013-03-24 17:48:06
那么,它*可能会完全在CSS中展开/折叠。我已经完成了,但这也取决于你想要的展开/折叠功能的复杂程度。没有关于你想要做什么的细节,我们无法真正帮助你。 – animuson 2013-03-24 17:48:16
@Mooseman其实它取决于... – PeeHaa 2013-03-24 17:51:26