【发布时间】:2021-04-28 23:33:01
【问题描述】:
我有一个简单 HTML 和 scss 格式的导航栏元素(图标和标题),当再次点击导航栏缩小只显示图标时,我该如何实现这样的东西?
.page-container {
display: flex;
height: 100%;
background: white;
}
.sidebar {
height: 100%;
width: 300px;
background: rgba(0, 0, 0, 0.8);
}
.list-items {
padding-top: 100px;
}
.list-item {
display: flex;
font-size: 20px;
color: white;
padding: 10px 20px;
color: rgba(255, 255, 255, 0.85);
cursor: pointer;
position: relative;
}
.list-item.selected {
color: white;
}
.list-item:hover {
color: #51bbe5;
}
.list-item:hover::before {
opacity: 0.35;
transform: scaleY(0.5) scaleX(2);
}
.list-item::before {
content: "";
position: absolute;
height: 100%;
width: 3px;
top: 0;
left: 0;
background-color: #51bbe5;
/* set opacity to 0 by default */
opacity: 0;
transform: scaleY(0);
transition: transform 0.2s, opacity 0.2s;
}
.list-item.selected::before {
opacity: 1;
transform: scaleY(1);
}
.list-item span.material-icons-outlined {
margin-right: 12px;
}
.page-content-container {
padding: 50px;
}
<div class="page-container">
<div class="sidebar">
<div class="list-items">
<a class="list-item">
<span class="material-icons-outlined"> source </span>New reconciliation
</a>
<a class="list-item">
<span class="material-icons-outlined"> source </span>Reports history
</a>
<a class="list-item">
<span class="material-icons-outlined"> drive_folder_upload </span
>Uploaded files history
</a>
<a routerLink="/reports" routerLinkActive="selected" class="list-item">
<span class="material-icons-outlined"> description </span>Logout
</a>
</div>
</div>
<div class="page-content-container">
</div>
</div>
【问题讨论】:
-
您提供的代码似乎不完整。 “小按钮”在哪里?你是用JS触发菜单吗?请阅读how to create a minimal reproducible example。
-
嘿@disinfor 小按钮只是一个示例来阐明所需的输出,我的想法是我将使用一个按钮而不是像悬停这样的其他东西..;
标签: javascript html css sass