【发布时间】:2013-08-16 01:53:23
【问题描述】:
我想做的是在屏幕上显示很多卡片。当您单击它们时,它们应该旋转并改变它们的颜色。 我遇到的问题是,无论我点击哪张卡片,只有第一张卡片发生变化,而不是被点击的卡片。
这是一个小提琴:
html:
<body>
<div class="pane">
<input type="checkbox" id="button">
<label class="card" for="button"></label>
<input type="checkbox" id="button">
<label class="card" for="button"></label>
<input type="checkbox" id="button">
<label class="card" for="button"></label>
<input type="checkbox" id="button">
<label class="card" for="button"></label>
</div>
</body>
css:
input
{
width:100px;
height:100px;
display:none
}
.card
{
width:100px;
height:100px;
background:red;
display:block;
transition: background 1s, -webkit-transform 1s;
}
input:checked +.card
{
background:blue;
-webkit-transform: rotateX(180deg);
}
谢谢
【问题讨论】:
-
CSS 中没有“第一个兄弟”选择器。您需要使用 JavaScript。
标签: css