CSS100Day(7)-菜单列表和公告在一起
1063 字
5 分钟
CSS100Day(7)-菜单列表和公告在一起
设计简介
没有什么可以介绍的,直接看代码,都是简单元素堆叠
效果展示
通知公告
上午 9:24
陈小秋 在墙上贴了个照片
上午 8:19
陈打球 评论了你的上一个帖子
昨天
陈月玲 添加了你的好友
实现代码和步骤
HTML部分
<body> <div class="frame"> <div class="panel"> <div class="header"> <div class="menu-icon"> <div class="dash-top"></div> <div class="dash-bottom"></div> <div class="circle"></div> </div> <div class="title">通知公告</div> </div> <div class="notifications"> <div class="line"></div> <div class="notification"> <div class="circle"></div> <div class="time">上午 9:24</div> <p><b>陈小秋</b> 在墙上贴了个照片</p> </div> <div class="notification"> <div class="circle"></div> <div class="time">上午 8:19</div> <p><b>陈打球</b> 评论了你的上一个帖子</p> </div> <div class="notification"> <div class="circle"></div> <div class="time">昨天</div> <p><b>陈月玲</b> 添加了你的好友</p> </div> </div> </div> <div class="menu"> <ul> <li><span>仪表盘</span></li> <li><span>概述</span></li> <li><span>通知公告</span></li> <li><span>消息</span></li> <li><span>设置</span></li> </ul> </div> </div> <script> const menuIcon = document.querySelector(".menu-icon") const panel = document.querySelector(".panel") const menu = document.querySelector(".menu") menuIcon.addEventListener("click", () => { panel.classList.toggle("show-menu") menu.classList.toggle("show-menu") }) </script></body>CSS部分
:root { --blue: #5f98cd; --blue-dark: #264057; --blue-light: #b2daff; font-family: "微软雅黑";}
.frame { position: relative; width: 400px; height: 400px; border-radius: 2px; box-shadow: 1px 2px 10px 0px rgba(0, 0, 0, 0.3); background: var(--blue-dark); overflow: hidden;}
.panel { position: absolute; z-index: 2; width: 300px; height: 300px; top: 50px; left: 50px; background: #fff; border-radius: 3px; overflow: hidden; box-shadow: 10px 10px 15px 0 rgba(0, 0, 0, 0.3); transition: all 0.5s ease-in-out;
/* 添加.show-menu类样式右移动 */ &.show-menu { transform: translate3d(150px, 0, 0); }
.header { height: 60px; width: 100%; background: var(--blue);
.menu-icon { position: absolute; width: 29px; height: 15px; top: 23px; left: 20px; cursor: pointer;
&:hover { .dash-top, .dash-bottom, .circle { background-color: #fff; } }
.dash-top { position: absolute; width: 20px; height: 3px; top: 0; left: 0; background: var(--blue-light); transition: all 0.2s; border-radius: 3px; }
.dash-bottom { position: absolute; width: 29px; height: 3px; bottom: 0; background: var(--blue-light); transition: all 0.2s; border-radius: 3px; }
.circle { position: absolute; width: 7px; height: 7px; background: var(--blue-light); top: -2px; right: 0; border-radius: 50%; transition: all 0.2s; } }
.title { color: #fff; line-height: 60px; text-align: center; } }
.notifications { position: relative; height: 100%; overflow: hidden;
.line { position: absolute; top: 0; left: 27px; bottom: 0; width: 3px; background: #ebebeb; }
.notification { position: relative; z-index: 2; margin: 32px 20px 25px 43px;
&:hover { color: var(--blue); cursor: pointer; }
.circle { box-sizing: border-box; position: absolute; height: 11px; width: 11px; background: #fff; border: 2px solid var(--blue); box-shadow: 0 0 0 3px #fff; border-radius: 6px; top: 0; left: -20px; }
.time { display: block; font-size: 11px; line-height: 11px; margin-bottom: 8px; }
p { font-size: 15px; line-height: 20px; margin: 0;
b { font-weight: 600; } } } }}
.menu { width: 170px; height: 270px; color: var(--blue-light); position: absolute; top: 65px; left: 50px; background: #43627d; transition: all 0.5s ease-in-out; transform: translate3d(20px, 0, 0);
&.show-menu { transform: translate3d(0, 0, 0); }
ul { list-style: none; margin: 0; padding: 10px 0;
li { color: #93b2cd; margin: 0; padding: 18px 17px; list-style: none; font-size: 14px; line-height: 14px; transition: all 0.3s; cursor: pointer;
&:hover { color: #fff; background: #385269; } } }}分享给其他人
如果该文章对您有帮助,欢迎分享给其他人阅读!
复制链接
相关文章
推荐筛选
1
CSS100Day(2)-菜单按钮动画
设计灵感 菜单按钮都见过,但是三根条动画实现,关键利用no-animation初始化时候关闭回复动画
2
CSS100Day(13)-图片hover上方出现蒙层和元素
设计灵感 图片hover常规出现蒙层和元素,点击后过渡呈现卡片内容
3
CSS100Day(6)-卡片练习和绝对定位圆圈
设计灵感 头像外两个嵌套圆圈绝对定位技巧,以及利用filter实现hover加深
4
CSS100Day(3)-clip-path和动画实现金字塔日出日落
设计灵感 一个训练clip-path和关键帧贝塞尔曲线的练习
5
CSS100Day(18)-3D实现弹性元素
设计灵感 3D实现弹性元素
随机文章
随机推荐