标签:port class spl margin for inter 技术 png div
效果:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div class="tab">
<label for="tab1">
<div class="tab-item">手风琴</div>
</label>
<input type="radio" name="tab" id="tab1" checked>
<div class="tab-content-item">1</div>
<label for="tab2">
<div class="tab-item">radio + 相邻兄弟选择器</div>
</label>
<input type="radio" name="tab" id="tab2">
<div class="tab-content-item">2</div>
<label for="tab3">
<div class="tab-item">label</div>
</label>
<input type="radio" name="tab" id="tab3">
<div class="tab-content-item">3</div>
<label for="tab4">
<div class="tab-item">属性选择器</div>
</label>
<input type="radio" name="tab" id="tab4">
<div class="tab-content-item">4</div>
</div>
</body>
</html>
<style>
.tab {
width: 200px;
}
.tab-item {
width: 200px;
border: 1px solid #ddd;
margin-right: 5px;
text-align: center;
cursor: pointer;
}
input[type="radio"]:checked + .tab-item {
background: #ddd;
}
.tab-item:last-of-type {
margin-right: 0;
}
.tab-content {
border: 1px solid #ddd;
margin-top: 10px;
width: 200px;
height: 200px;
}
.tab-content-item {
display: none;
width: 200px;
height: 200px;
text-align: center;
border: 1px solid #ddd;
background: #ddd;
}
input[type="radio"] {
display: none;
}
input[type="radio"]:checked + .tab-content-item {
display: block;
}
</style>
利用这个 radio + 属性选择器 + 兄弟相邻选择器 + label的关联 还可以实现tab选项卡,如果你正在看这个文章,不妨动手试试
标签:port class spl margin for inter 技术 png div
原文地址:https://www.cnblogs.com/xiaolantian/p/13281005.html