-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[css] 第254天 如何使用CSS绘制一个汉堡式菜单 #1695
Comments
比较常见的两种方法:
.burger {
--width: 20px;
--thickness: 4px;
--color: black;
display: inline-block;
width: var(--width);
height: var(--thickness);
background-color: var(--color);
background-clip: content-box;
border-top: solid var(--thickness) var(--color);
border-bottom: solid var(--thickness) var(--color);
padding-top: var(--thickness);
padding-bottom: var(--thickness);
} |
/* 需要父级设定高度,嘤嘤嘤 */
/* 汉堡式菜单图标,宽高尺寸,线条粗细,线条颜色 */
@mixin menu($size: 50px, $thick: 3px, $color: #000) {
$_size: $size / 2 - $thick;
width: $size;
box-shadow: 0 0 0 $thick $color, 0 -1 * $_size 0 $thick $color, 0 $_size 0 $thick $color;
}
.menu { @include menu(); } |
666,利用阴影挺机智的,只是阴影没有点击判定,所以只能通过点击中间的横线才能生效,会有点奇怪。 |
汉堡式菜单是一种非常流行的响应式导航菜单,可以在移动设备和桌面浏览器上实现便捷的用户导航。下面是使用 CSS 绘制一个汉堡式菜单的基本思路: HTML 结构:使用 元素作为菜单容器,内部包含三个 元素作为汉堡菜单的条线。
.hamburger-menu { .hamburger-menu span { .hamburger-menu span:nth-child(1) { .hamburger-menu span:nth-child(2), .hamburger-menu span:nth-child(3) { .hamburger-menu.active span:nth-child(1) { .hamburger-menu.active span:nth-child(2) { .hamburger-menu.active span:nth-child(3) { const menu = document.querySelector('.hamburger-menu'); |
第254天 如何使用CSS绘制一个汉堡式菜单
作者:cxwht
我也要出题
使用CSS绘制一个汉堡式菜单,即选单按钮上的三条平行横线图标
The text was updated successfully, but these errors were encountered: