Плавающее адаптивное вертикальное меню на CSS3 и jQuery
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
@import "//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.0.3/css/font-awesome.min.css" all; .menu,.menu-bar { position: fixed; top: 0; left: 0; height: 100%; list-style-type: none; margin: 0; padding: 0; background: #f7f7f7; z-index: 10; overflow: hidden; box-shadow: 2px 0 18px rgba(0,0,0,0.26); } .menu li a { display: block; text-indent: -500em; height: 5em; width: 5em; line-height: 5em; text-align: center; color: #72739f; position: relative; border-bottom: 1px solid rgba(0,0,0,0.05); transition: background .1s ease-in-out; } .menu li a:before { font-family: FontAwesome; speak: none; text-indent: 0; position: absolute; top: 0; left: 0; width: 100%; height: 100%; font-size: 1.4em; } .menu li a.search:before { content: "\f002"; } .menu li a.archive:before { content: "\f187"; } .menu li a.pencil:before { content: "\f040"; } .menu li a.contact:before { content: "\f003"; } .menu li a.about:before { content: "\f007"; } .menu li a.home:before { content: "\f039"; } .menu-bar li a:hover,.menu li a:hover,.menu li:first-child a { background: #267fdd; color: #fff; } .menu-bar { overflow: hidden; left: 5em; z-index: 5; width: 0; height: 0; transition: all .1s ease-in-out; } .menu-bar li a { display: block; height: 4em; line-height: 4em; text-align: center; color: #72739f; text-decoration: none; position: relative; font-family: verdana; border-bottom: 1px solid rgba(0,0,0,0.05); transition: background .1s ease-in-out; } .menu-bar li:first-child a { height: 5em; background: #267fdd; color: #fff; line-height: 5; } .para { color: #033f72; padding-left: 100px; font-size: 3em; margin-bottom: 20px; } .open { width: 10em; height: 100%; } @media all and (max-width: 500px) { .container { margin-top: 100px; } .menu { height: 5em; width: 100%; } .menu li { display: inline-block; float: left; } .menu-bar li a { width: 100%; } .menu-bar { width: 100%; left: 0; height: 0; } .open { width: 100%; height: auto; } .para { padding-left: 5px; } } @media screen and (max-height: 34em) { .menu li,.menu-bar { font-size: 70%; } } @media screen and (max-height: 34em) and (max-width: 500px) { .menu { height: 3.5em; } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
<ul class="menu"> <li><a href="#" class="menu-button home" onclick="$('.menu-bar').toggleClass('open');">menu</a></li> <li><a href="#" class="search">search</a></li> <li><a href="#" class="pencil">pencil</a></li> <li><a href="#" class="active about">about</a></li> <li><a href="#" class="archive">archive</a></li> <li><a href="#" class="contact">contact</a></li> </ul> <ul class="menu-bar"> <li><a href="#" class="menu-button">Меню</a></li> <li><a href="#">На главную</a></li> <li><a href="#">Профиль</a></li> <li><a href="#">Статьи</a></li> <li><a href="#">О нас</a></li> </ul> <script> $(".menu-button").click(function(){ $(".menu-bar").toggleClass( "open" ); }); </script> |
Без JS не пашет.
Спасибо, исправил