{"id":207286,"date":"2015-09-01T13:31:40","date_gmt":"2015-09-01T20:31:40","guid":{"rendered":"http:\/\/css-tricks.com\/?page_id=207286"},"modified":"2021-09-02T07:20:51","modified_gmt":"2021-09-02T14:20:51","slug":"apple-com-hamburger-bun-menu","status":"publish","type":"page","link":"https:\/\/css-tricks.com\/snippets\/css\/apple-com-hamburger-bun-menu\/","title":{"rendered":"Apple.com Hamburger Bun Menu"},"content":{"rendered":"
Apple made some noise when they released an updated site<\/a>, including an all-new responsive navigation. While the redesign was focused on other things, one thing that stuck out was the use of a hamburger menu icon<\/a> in a newly designed responsive navigation. And, not just any hamburger, a meatless one—just the buns. It could be a statement on simplicity or whatever, but here’s how we can recreate it with the same animated effect that transforms the icon from a hamburger to an \u00d7.<\/p>\n The following code assumes the use of autoprefixer.<\/p>\n See the Pen Apple’s Hamburger Buns Menu<\/a> by CSS-Tricks (@css-tricks<\/a>) on CodePen<\/a>.<\/p>\n.hamburger {\r\n cursor: pointer;\r\n position: absolute;\r\n width: 48px;\r\n height: 48px;\r\n transition: all 0.25s;\r\n}\r\n\r\n.hamburger__top-bun,\r\n.hamburger__bottom-bun {\r\n content: '';\r\n display: block;\r\n position: absolute;\r\n left: 15px;\r\n width: 18px;\r\n height: 1px;\r\n background: #fff;\r\n transform: rotate(0);\r\n transition: all 0.25s;\r\n}\r\n\r\n.hamburger:hover [class*=\"-bun\"] {\r\n background: #999;\r\n}\r\n\r\n.hamburger__top-bun {\r\n top: 23px;\r\n transform: translateY(-3px);\r\n}\r\n\r\n.hamburger__bottom-bun {\r\n bottom: 23px;\r\n transform: translateY(3px);\r\n}\r\n\r\n.open {\r\n transform: rotate(90deg);\r\n}\r\n\r\n.open .hamburger__top-bun {\r\n transform: \r\n rotate(45deg) \r\n translateY(0px);\r\n}\r\n\r\n.open .hamburger__bottom-bun {\r\n transform: \r\n rotate(-45deg) \r\n translateY(0px);\r\n} <\/code><\/pre>\n
$('.hamburger').click (function(){\r\n $(this).toggleClass('open');\r\n});<\/code><\/pre>\n
Other Examples<\/h3>\n