div+css布局可折叠文件树目录树代码
代码语言:html
所属分类:布局界面
代码描述:div+css布局可折叠文件树目录树代码
代码标签: div css 布局 可 折叠 文件树 目录树 代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum=1.0,minimum=1.0,user-scalable=0" />
<style>
body{
margin: 200px ;
}
.tree-container {
width: 320px;
border: 1px solid #e4e4e7;
border-radius: 8px;
padding: 24px;
background: #fff;
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}
ul {
list-style: none;
padding: 0;
margin: 0;
}
ul ul {
margin-left: 11px;
padding-left: 11px;
border-left: 1px solid #e4e4e7;
}
.tree-item {
position: relative;
margin-top: 4px;
}
ul ul .tree-item::before {
content: "";
position: absolute;
left: -11px;
top: 14px;
width: 11px;
height: 1px;
background-color: #e4e4e7;
}
.tree-label,
.file-item {
display: flex;
align-items: center;
gap: 8px;
padding: 4px 8px;
border-radius: 4px;
cursor: pointer;
font-size: 14px;
color: #09090b;
transition: background-color 0.2s;
user-select: none;
text-decoration: none;
height: 28px;
}
.tree-label:hover,
.file-item:hover {
background-color: #f4f4f5;
}
.is-selected {
background-color: #f4f4f5;
color: #09090b;
font-weight: 500;
}
.icon {
width: 16px;
height: 16px;
color: #71717a;
flex-shrink: 0;
}
.folder-open-icon {
display: none;
}
.folder-closed-icon {
display: block;
}
.tree-toggle:checked ~ .tree-label .folder-open-icon {
display: block;
color: #09090b;
}
.tree-toggle:checked ~ .tree-label .folder-closed-icon {
display: none;
}
.tree-toggle {
display: none;
}
.tree-children-wrapper {
display: grid;
grid-template-rows: 0fr;
transition: grid-template-rows 0.3s ease-in-out;
}
.tree-children {
overflow: hidden;
}
/* State: Open .........完整代码请登录后点击上方下载按钮下载查看
















网友评论0