cssのアニメーションで 「ハンバーガーメニュー(パート2)」 アイコンを作成してみました。クリックするとメニューが動きます。
ソース
html
<div id="svg_box_02" class="svg_box"> <input type="checkbox" class="menu_open" name="menu_open_02" id="menu_open_02"> <label class="menu_open_button menu_button_02" for="menu_open_02" id="menu_open_button_02"> <span class="hamburger hamburger_1"></span> <span class="hamburger hamburger_2"></span> <span class="hamburger hamburger_3"></span> </label> </div> <svg xmlns="http://www.w3.org/2000/svg" version="1.1"> <defs> <filter id="filter_02"> <feGaussianBlur in="SourceGraphic" stdDeviation="10" result="blur" /> <feColorMatrix in="blur" mode="matrix" values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 19 -9" result="filter_02" /> <feComposite in="SourceGraphic" in2="filter_02" operator="atop"/> </filter> </defs> </svg>
css
svg { position: absolute; top: 0; left: 0; width: 0; height: 0; } .svg_box { position: relative; display: block; text-align: center; margin: 0; width: 160px; height: 160px; } .menu_open { display: none; } .menu_open_button { position: absolute; top: 0; left: 0; width: 160px; height: 160px; color: #fff; text-align: center; line-height: 160px; background: #39a9d6; border-radius: 100%; -webkit-transition-timing-function: ease; transition-timing-function: ease; -webkit-transition-duration: 400ms; transition-duration: 400ms; -webkit-transform: scale(1.0, 1.0) translate3d(0, 0, 0); transform: scale(1.0, 1.0) translate3d(0, 0, 0); cursor: pointer; } .hamburger { display: block; position: absolute; top: 50%; left: 50%; margin-left: -30px; margin-top: -3px; width: 60px; height: 3px; background: #fff; -webkit-transition: -webkit-transform 200ms; transition: transform 200ms; } .hamburger_1 { -webkit-transform: translate3d(0, -24px, 0); transform: translate3d(0, -24px, 0); } .hamburger_2 { -webkit-transform: translate3d(0, 0, 0); transform: translate3d(0, 0, 0); } .hamburger_3 { -webkit-transform: translate3d(0, 24px, 0); transform: translate3d(0, 24px, 0); } #svg_box_02 { -webkit-filter: url("#filter_02"); filter: url("#filter_02"); } /* checkbox */ #menu_open_02:checked + #menu_open_button_02 .hamburger_1 { -webkit-transform: translate3d(0, 0, 0) rotate(225deg) scale(1.2, 1.2); transform: translate3d(0, 0, 0) rotate(225deg) scale(1.2, 1.2); } #menu_open_02:checked + #menu_open_button_02 .hamburger_2 { -webkit-transform: translate3d(0, 0, 0) scale(0.1, 1); transform: translate3d(0, 0, 0) scale(0.1, 1); } #menu_open_02:checked + #menu_open_button_02 .hamburger_3 { -webkit-transform: translate3d(0, 0, 0) rotate(-225deg) scale(1.2, 1.2); transform: translate3d(0, 0, 0) rotate(-225deg) scale(1.2, 1.2); }