【发布时间】:2018-03-23 07:47:35
【问题描述】:
我正在尝试实现背景转换,当您单击选项卡时,当前选项卡的背景会滑动到单击的选项卡。有人可以帮忙吗?
*,
*:before,
*:after {
box-sizing: border-box;
}
.radio_wrap {}
input {
position: absolute;
opacity: 0;
}
label {
min-width: calc(100% / 4);
position: relative;
float: left;
text-align: center;
text-shadow: none;
padding: 20px;
border: 1px solid #dfe0e4;
color: grey;
font-size: 14px;
position: relative;
transition: background-color .3s ease-in-out;
}
input:checked+label {
background: grey;
color: white;
}
<div class="radio_wrap">
<input type="radio" id="radio1" name="radio1">
<label for="radio1">tab1</label>
<input type="radio" id="radio2" name="radio1">
<label for="radio2">tab2</label>
<input type="radio" id="radio3" name="radio1">
<label for="radio3">tab3</label>
<input type="radio" id="radio4" name="radio1">
<label for="radio4">tab4</label>
</div>
【问题讨论】:
-
澄清一下,您提供的代码笔没有“幻灯片”过渡。它只是让背景颜色淡入。
-
是的,但不是让它淡入,是否可以让它在点击时滑动到下一个标签?
标签: css css-transitions css-animations