SWANKY PURE CSS DROP DOWN MENU
Pure CSS drop down menu. Nice little addition to any non-javascript user interface. Uses the labels for trick to toggle animations.
Demo Below
See the Pen SWANKY PURE CSS DROP DOWN MENU by ogbugbu (@ogbugbu) on CodePen.
<HTML CODE>
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 |
// Begin Body .swanky // Introduction Block .swanky_title %h1 Swanky Lil Drop Down Menu V2.0 %p Pure CSS Drop down menu. Nice little addition to any non-javascript user interface. Uses the labels for trick to toggle animations. .swanky_title__social %a{:href => 'https://www.twitter.com/jamiecoulter89',:target => '_blank'} .slide .arrow .stem .point %img{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/tw.png'} Twitter .swanky_title__social %a{:href => 'https://www.codepen.io/jcoulterdesign/',:target => '_blank'} .slide .arrow .stem .point %img{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/cp.png'} Codepen //////////// Begin Dropdown //////////// .swanky_wrapper %input{:type => 'radio',:name => 'radio',:id => 'Dashboard'} %label{:for => 'Dashboard'} %img{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/dash.png'} %span Dashboard %div.lil_arrow %div.bar .swanky_wrapper__content %ul %li Tools %li Reports %li Analytics %li Code Blocks %input{:type => 'radio',:name => 'radio',:id => 'Sales'} %label{:for => 'Sales'} %img{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/del.png'} %span Sales %div.lil_arrow %div.bar .swanky_wrapper__content %ul %li New Sales %li Expired Sales %li Sales Reports %li Deliveries %input{:type => 'radio',:name => 'radio',:id => 'Messages'} %label{:for => 'Messages'} %img{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/mess.png'} %span Messages %div.lil_arrow %div.bar .swanky_wrapper__content %ul %li Inbox %li Outbox %li Sent %li Archived %input{:type => 'radio',:name => 'radio',:id => 'Users'} %label{:for => 'Users'} %img{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/users.png'} %span Users %div.lil_arrow %div.bar .swanky_wrapper__content %ul %li New User %li User Groups %li Permissions %li Passwords %input{:type => 'radio',:radio => 'radio',:id => 'Settings'} %label{:for => 'Settings'} %img{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/set.png'} %span Settings %div.lil_arrow .swanky_wrapper__content %ul %li Databases %li Design %li Change User %li Log Out //////////// End Dropdown //////////// // My Footer .love %p Made with <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/love_copy.png" /> by <a href='https://www.jamiecoulter.co.uk' target='_blank'> Jcoulterdesign </a> |
<<CSS CODE>>
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 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 |
// Import Fonts @import url(https://fonts.googleapis.com/css?family=Roboto:400,700,300); // Roboto // Variables $default-font:'Roboto', sans-serif; // Roboto Google font $global-font-size:12px; // Global font sizing $global-font-weight:500; // Global font weight $global-font-smoothing:antialiased; // Global smoothing method $content-width:700px; // Width of wrapper $background:linear-gradient(135deg, #8254EA 0%, #E86DEC 100%); // Body background $full-height: 100vh; // Height of body $title-width:400px; // Width of title block // Reset ul{padding:0;margin:0;}li{list-style-type:none;}input[type='radio']{display:none;}label{cursor:pointer}::-webkit-scrollbar {display: none; } // Placeholders %center{ margin:auto; top:0; bottom:0; left:0; right:0; } // Styles body{ height: $full-height; font-weight: $global-font-weight; font-family:$default-font; background:$background; -webkit-font-smoothing: $global-font-smoothing; font-size: $global-font-size; .swanky{ @extend %center; perspective:600px; width:$content-width; position:absolute; margin:auto; height:360px; &_title{ float:right; text-align:left; width:$title-width; color:white; position:relative; top:70px; &__social a{ position:relative; overflow:hidden; .slide{ height: 45px; width: 100px; float: left; position: absolute; transform: skew(20deg); left: -120px; transition-property:left; transition-duration:.2s; background: white; .arrow{ position: absolute; right: 31px; top: 24px; opacity:0; transform: skew(-20deg); .stem{ width: 10px; height: 2px; background: rgb(133, 132, 144); } .point{ width: 6px; height: 6px; border-right: 2px solid rgb(133, 132, 144); top: -3px; right: 1px; position: absolute; transform: rotate(45deg); border-top: 2px solid rgb(133, 132, 144); } } } width: 140px; margin-right: 15px; text-decoration:none; padding: 0px 0px 5px 0px; height: 40px; border: 2px solid white; float: left; color: white; font-size: 12px; font-weight: 400; margin-top:20px; img{ width: 16px; margin-left: 10px; position: relative; margin-right: 8px; transition-property:margin-left; transition-duration:.1s; margin-top: 10px; top: 4px; } &:hover > .slide{ left:-70px; transition-property:left; transition-duration:.1s; } &:hover > img{ margin-left:40px; transition-property:margin-left; transition-duration:.1s; } &:hover > .slide .arrow{ right:11px; opacity:1; transition-property:right,opacity; transition-delay:.07s; transition-duration:.2s; } } } .intro{ float:right; color:white; width:370px; top:50px; position:relative; h1{ text-shadow: 0px 2px rgba(0, 0, 0, 0.26); } p{ line-height:20px; text-shadow: 0px 1px rgba(0, 0, 0, 0.26); } } &_wrapper{ width: 225px; //transform: rotateY(14deg) rotateX(-2deg) rotateZ(-2deg); height: auto; overflow: hidden; border-radius: 4px; background: #2a394f; label{ padding:25px; float:left; height:72px; border-bottom: 1px solid #293649; position:relative; width:100%; color:rgb(239, 244, 250); transition:text-indent .15s, height .3s; box-sizing:border-box; img{ margin-right:10px; position:relative; top: 2px; width:16px; } span{ position :relative; top:-3px } &:hover{ background: rgb(33, 46, 65); border-bottom: 1px solid #2A394F; text-indent:4px; } &:hover .bar{ width:100%; } .bar{ width: 0px; transition:width .15s; height: 2px; position: absolute; display: block; background: rgb(53, 87, 137); bottom: 0; left: 0; } .lil_arrow{ width:5px; height:5px; -webkit-transition: transform 0.8s; transition: transform 0.8s; -webkit-transition-timing-function: cubic-bezier(0.68, -0.55, 0.265, 1.55); border-top:2px solid white; border-right:2px solid white; float:right; position:relative; top: 6px; right: 2px; transform:rotate(45deg) } } &__content{ position: absolute; display: none; overflow: hidden; left: 0; width: 100%; li{ width:100%; opacity:0; left:-100%; background: #15a4fa; padding:25px 0px; text-indent:25px; box-shadow: 0px 0px #126CA1 inset; transition:box-shadow .3s,text-indent .3s; position:relative; &:hover{ background:#0c93e4; box-shadow: 3px 0px #126CA1 inset; transition:box-shadow .3s linear,text-indent .3s linear; text-indent:31px; } } .clear{ clear:both; } } } } } // Hide show content input[type='radio']:checked + label .swanky_wrapper__content{ display: block; top: 68px; border-bottom: 1px solid rgb(33, 46, 65); } input[type="radio"]:checked + label > .lil_arrow { -webkit-transition: -webkit-transform 0.8s; transition: transform 0.8s; -webkit-transition-timing-function: cubic-bezier(0.68, -0.55, 0.265, 1.55); -webkit-transform: rotate(135deg); -ms-transform: rotate(135deg); transform: rotate(135deg); border-top: 2px solid rgb(20, 163, 249); border-right: 2px solid rgb(20, 163, 249); } input[type='radio']:checked + label{ height: 325px;background: #212e41; text-indent:4px; transition-property:height; transition-duration:.6s; -webkit-transition-timing-function: cubic-bezier(0.68, -0.55, 0.265, 1.55); } input[type='radio']:checked + label .bar{ width:0; } input[type='radio']:checked + label{ @for $i from 1 through 4{ li:nth-of-type(#{$i}){ animation:in .15s .45s + $i/8 forwards; -webkit-transition-timing-function: cubic-bezier(0.68, -0.55, 0.265, 1.55); -moz-animation:in .15s .45s + $i/8 forwards; -moz-transition-timing-function: cubic-bezier(0.68, -0.55, 0.265, 1.55); } } } // Animations @keyframes in{ from{left:-100%;opacity:0} to{left:0;opacity:1} } // My Styles .love{ position: absolute; right: 20px; bottom: 0px; font-size: 11px; font-weight: normal; p{ color:white; font-weight:normal; font-family: 'Open Sans', sans-serif; } a{ color:white; font-weight:700; text-decoration:none; } img{ position:relative; top:3px; margin:0px 4px; width:10px; } } .brand{ position:absolute; left:20px; bottom:14px; img{ width:30px; } } |

ACCORDION MENU
Simple accordion menu with HTML, CSS and JavaScript.
DEMO BELOW
See the Pen Accordion Menu by ogbugbu (@ogbugbu) on CodePen.
<<HTML CODE>>
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 |
<h2>Favorite books</h2> <ul class="accordion-menu"> <li> <div class="dropdownlink"><i class="fa fa-road" aria-hidden="true"></i> History <i class="fa fa-chevron-down" aria-hidden="true"></i> </div> <ul class="submenuItems"> <li><a href="#">History book 1</a></li> <li><a href="#">History book 2</a></li> <li><a href="#">History book 3</a></li> </ul> </li> <li> <div class="dropdownlink"><i class="fa fa-paper-plane" aria-hidden="true"></i> Fiction <i class="fa fa-chevron-down" aria-hidden="true"></i> </div> <ul class="submenuItems"> <li><a href="#">Fiction book 1</a></li> <li><a href="#">Fiction book 2</a></li> <li><a href="#">Fiction book 3</a></li> </ul> </li> <li> <div class="dropdownlink"><i class="fa fa-quote-left" aria-hidden="true"></i> Fantasy <i class="fa fa-chevron-down" aria-hidden="true"></i> </div> <ul class="submenuItems"> <li><a href="#">Fantasy book 1</a></li> <li><a href="#">Fantasy book 2</a></li> <li><a href="#">Fantasy book 3</a></li> </ul> </li> <li> <div class="dropdownlink"><i class="fa fa-motorcycle" aria-hidden="true"></i> Action <i class="fa fa-chevron-down" aria-hidden="true"></i> </div> <ul class="submenuItems"> <li><a href="#">Action book 1</a></li> <li><a href="#">Action book 2</a></li> <li><a href="#">Action book 3</a></li> </ul> </li> </ul> |
<<CSS CODE>>
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 |
* { margin: 0; padding: 0; } body { font-family: 'Montserrat', sans-serif; background: #388E3C; } ul { list-style: none; } a { text-decoration: none; } h2 { text-align: center; margin: 20px auto; color: #fff; } .accordion-menu { width: 100%; max-width: 350px; margin: 60px auto 20px; background: #fff; border-radius: 4px; } .accordion-menu li.open .dropdownlink { color: #CDDC39; .fa-chevron-down { transform: rotate(180deg); } } .accordion-menu li:last-child .dropdownlink { border-bottom: 0; } .dropdownlink { cursor: pointer; display: block; padding: 15px 15px 15px 45px; font-size: 18px; border-bottom: 1px solid #ccc; color: #212121; position: relative; transition: all 0.4s ease-out; i { position: absolute; top: 17px; left: 16px; } .fa-chevron-down { right: 12px; left: auto; } } .submenuItems { display: none; background: #C8E6C9; li { border-bottom: 1px solid #B6B6B6; } } .submenuItems a { display: block; color: #727272; padding: 12px 12px 12px 45px; transition: all 0.4s ease-out; &:hover { background-color: #CDDC39; color: #fff; } } |
<<JS CODE>>
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 |
$(function() { var Accordion = function(el, multiple) { this.el = el || {}; // more then one submenu open? this.multiple = multiple || false; var dropdownlink = this.el.find('.dropdownlink'); dropdownlink.on('click', { el: this.el, multiple: this.multiple }, this.dropdown); }; Accordion.prototype.dropdown = function(e) { var $el = e.data.el, $this = $(this), //this is the ul.submenuItems $next = $this.next(); $next.slideToggle(); $this.parent().toggleClass('open'); if(!e.data.multiple) { //show only one menu at the same time $el.find('.submenuItems').not($next).slideUp().parent().removeClass('open'); } } var accordion = new Accordion($('.accordion-menu'), false); }) |