进阶实战 css 点击按钮的样式
作者:互联网
1. html结构
<div class="menu-wrap"> <input type="checkbox" class="toggler"> <div class="hamburger"><div></div></div> <div class="menu"> <div> <ul> <li><a href="#">Home</a></li> <li><a href="#">About</a></li> <li><a href="#">Serices</a></li> <li><a href="#">Contact</a></li> </ul> </div> </div> </div>
2. css 样式
.menu-wrap { position: fixed; top: 0; left: 0; z-index: 1; } .menu-wrap .toggler { position: absolute; top: 0; left: 0; z-index: 2; /* 控制光标的类型 */ cursor: pointer; width: 60px; height: 60px; opacity: 0; } .menu-wrap .hamburger { position: absolute; top: 0; left: 0; z-index: 1; width: 60px; height: 60px; padding: 1rem; background: var(--primary--color); display: flex; justify-content: center; align-content: center; } /* hamburger line */ .menu-wrap .hamburger > div { position: relative; flex: none; width: 100%; height: 2px; background: #fff; } /* hamburger liner -- top & bottom */ .menu-wrap .hamburger > div:before, .menu-wrap .hamburger > div:after{ content: ''; position: absolute; z-index: 1; background: #fff; width: 100%; height: 2px; top: 20px; } .menu-wrap .hamburger > div:after { top: 10px; }
3. 重点
伪类选择器
:before 选择器在被选元素的内容前面插入内容.
:after 选择器在被选元素的内容前面插入内容.
标签:hamburger,进阶,menu,top,height,按钮,wrap,position,css 来源: https://www.cnblogs.com/wqddmghsdfh/p/16061925.html