今日完成
修改task6 使两按钮可滑动
学习bootstrap滑动门的使用
明日计划
完成task8
学习滑动门

.nav .nav-pills创建导航栏样式
.nav-link创建连接样式
.tab-content创建滑动门区域
href链接.tab-content下文本的id
role,data-toggle ,aria-controls ,aria-selected ,aria-labelledby
无障碍处理 辅助功能(如屏幕阅读器)
本想通过滑动门组件完成task6的页面切换
但滑动门仅有 fade 淡入淡出
后通过input radio单选框完成

html
<input id="toptab-left" type="radio" name="toptab">
<input id="toptab-right" checked="checked" type="radio" name="toptab">
<div class="toptab-wrap">
<label for="toptab-left" class="toptab-left">
<span>找雇主</span>
</label>
<label for="toptab-right" class="toptab-right">
<span>找护工</span>
</label>
</div>
css
input[type="radio"] {
display: none;
}
.toptab-wrap {
position: fixed;
top: 0.7vh;
left: 50%;
display: flex;
justify-content: space-around;
align-items: center;
width: 39.6vw;
height: 5.4vh;
background-color: #55a8b3;
border-radius: 0.7rem;
transform: translateX(-50%);
}
.toptab-wrap label {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
font-size: 2rem;
line-height: 5.4vh;
text-align: center;
transition: color 1s;
z-index: 99;
}
.toptab-wrap span{
color:#fff;
}
.toptab-wrap::before {
content: '';
position: absolute;
right: 0;
width: 50%;
height: 100%;
background-color: #fff;
border-radius: 0.7rem;
transition: all 0.5s;
z-index: 9;
}
#toptab-right:checked~.toptab-wrap>.toptab-right>span,
#toptab-left:checked~.toptab-wrap>.toptab-left>span {
color: #5fc0cd;
}
#toptab-left:checked~.toptab-wrap::before {
right: 50%;
}
#toptab-left:checked~main {
transform: translateX(-50%);
}
两个单选框设置相同name 使单选互斥
通过label for 链接input 以便自定义控制样式
主体width 200% 设为flex横向排列
外容器overflow:hidden 子元素width 50%
利用:checked 通过选框的checked状态对主体transform:translatex 平移
在通过transition完成过渡效果
checkbox也可完成同样效果 但每次点击都会触发checked
单选框可不重复触发

兄弟选择器~ +的 区别
区别
+近找最近符合条件的
~找所有符合条件的
相同 都只能向下查找

评论