How to make this CSS hamburger menu entirely clickable?

▼魔方 西西 提交于 2019-12-04 09:12:27

Just do this

DEMO - 1 (border top or bottom)

.menu {
    width:30px;
    height:20px;
    position:relative;
    display:inline-block;
    border-top:4px solid black;
}
	.menu:after, .menu:before {
	    content: '';
	    width: 100%;
	    height:4px;
	    background-color:#000;
	    position:absolute;
	}
	.menu:after {
	    bottom:0px;
	    left:0;
	}
	.menu:before {
	    top:6px;
	    left:0;
	}
<a href="#" title="Open Menu" class="menu"></a>

DEMO -2 (box-shadow)

.menu {
    width:30px;
    height:20px;
    position:relative;
    display:inline-block;
    box-shadow:inset 0 4px 0 black;
}
	.menu:after, .menu:before {
	    content: '';
	    width: 100%;
	    height:4px;
	    background-color:#000;
	    position:absolute;
	}
	.menu:after {
	    bottom:0px;
	    left:0;
	}
	.menu:before {
	    top:8px;
	    left:0;
	}
<a href="#" title="Open Menu" class="menu"></a>

DEMO - 3 (only :before or after mixed box-shadow inset)

.menu {
    width:30px;
    height:20px;
    position:relative;
    display:inline-block;
    box-shadow:inset 0 4px 0 black,inset 0 -4px 0 black;
}
	.menu:after{
	    content: '';
	    width: 100%;
	    height:4px;
	    background-color:#000;
	    position:absolute;
        top:8px;
	    left:0;
	}
<a href="#" title="Open Menu" class="menu"></a>

DEMO - 4

.menu {
    width:30px;
    height:14px;
    position:relative;
    display:inline-block;
    border-top: 4px solid black;
    border-bottom: 4px solid black;
}
	.menu:after{
	    content: '';
	    width: 100%;
	    height:4px;
	    background-color:#000;
	    position:absolute;
        top:5px;
	    left:0;
	}
<a href="#" title="Open Menu" class="menu"></a>

DEMO - 5 (using background image)

.menu {
width: 30px;
height: 26px;
position: relative;
display: inline-block;
background-size: 10px 10px;
background-image: -webkit-linear-gradient(rgba(0, 0, 0, 1) 50%, transparent 50%, transparent);
background-image: -moz-linear-gradient(rgba(0, 0, 0, 1) 50%, transparent 50%, transparent);
background-image: linear-gradient(rgba(0, 0, 0, 1) 50%, transparent 50%, transparent);
}
<a href="#" title="Open Menu" class="menu"></a>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!