Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <!-- Necessary for the icon font to work. -->
- <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
- <style>
- /** GLOBAL **/
- body {
- background: #8bc34a; /* green background color of the page*/
- color: white; /* text color of the page */
- text-align: center;
- /* could also be set to left, right, or justify */
- }
- /** LINKS **/
- a {
- color: inherit;
- /* links will have the same color as the global text; in this case , white */
- }
- /** HEADINGS **/
- h1, h2, h3, h4 {
- margin: 0;
- margin-bottom: 10px; /* margin to elements above */
- margin-top: 10px; /* margin to elements below */
- }
- /** FIRST HEADING **/
- h1 {
- font-size: 3em; /* 1em = 16px ; 3em = 48px */
- }
- /* I have played with this by commenting out the .menu{}, and apparently it does not affect the styling on the customization page. */
- .menu {
- filter: url("#goo");
- }
- /* These lines are very important as they are responsible for styling the whole menu. Without them, the icons just appear in one row. */
- .menu-item, .menu-open-button {
- background: #e91e63; /* pink background of the menu*/
- border-radius: 100%; /* minimum is 50% for a perfect circle */
- width: 80px; /* circle width */
- height: 80px; /* circle height */
- margin-left: -40px; /* offset from the left */
- position: absolute;
- top: 20px; /* offset from the top */
- color: white; /* color of the icons */
- text-align: center; /* horizontal centering of icons */
- line-height: 80px; /* vertical centering of icons */
- transform: translate3d(0, 0, 0);
- transition: transform ease-out 200ms;
- /* transformation and duration of the transformation */
- }
- /* These lines seemingly only affect the margin to the left. */
- .menu-open {
- display: none;
- }
- /* Hamburger menu (≡) within the pink circle. */
- .hamburger {
- width: 25px; /* line width */
- height: 3px; /* line height */
- background: white; /* color of the lines (≡) */
- display: block;
- position: absolute;
- top: 50%; /* offset from top */
- left: 50%; /* offset from left */
- /* since the lines are 25px long and 3px high, the following lines are necessary to center-align the menu properly */
- margin-left: -12.5px;
- margin-top: -1.5px;
- /* transformation duration */
- transition: transform 200ms;
- }
- .hamburger-1 {
- transform: translate3d(0, -8px, 0);
- /* (-8px) is the offset to the second line*/
- }
- .hamburger-2 {
- transform: translate3d(0, 0, 0);
- }
- .hamburger-3 {
- transform: translate3d(0, 8px, 0);
- /* (8px) is the offset to the second line*/
- }
- /* Upon clicking on the menu, the lines of the hamburger menu rotate and realign. The middle line is scaled down to 0, so that it disappeares. The top and bottom lines will be rotated so that they form an (x). */
- .menu-open:checked + .menu-open-button .hamburger-1 {
- transform: translate3d(0, 0, 0) rotate(45deg);
- }
- .menu-open:checked + .menu-open-button .hamburger-2 {
- transform: translate3d(0, 0, 0) scale(0, 1);
- }
- .menu-open:checked + .menu-open-button .hamburger-3 {
- transform: translate3d(0, 0, 0) rotate(-45deg);
- }
- .menu {
- position: absolute;
- left: 50%;
- margin-left: -190px;
- padding-top: 20px;
- padding-left: 190px;
- width: 380px;
- height: 250px;
- box-sizing: border-box;
- font-size: 20px;
- text-align: left;
- }
- .menu-item:hover {
- background: white;
- color: #e91e63;
- }
- /*
- duration for the items to be displayed
- the items are displayed after one another
- */
- .menu-item:nth-child(3) {
- transition-duration: 180ms;
- }
- .menu-item:nth-child(4) {
- transition-duration: 180ms;
- }
- .menu-item:nth-child(5) {
- transition-duration: 180ms;
- }
- .menu-item:nth-child(6) {
- transition-duration: 180ms;
- }
- .menu-item:nth-child(7) {
- transition-duration: 180ms;
- }
- .menu-item:nth-child(8) {
- transition-duration: 180ms;
- }
- .menu-item:nth-child(9) {
- transition-duration: 180ms;
- }
- .menu-open-button {
- z-index: 2;
- transition-timing-function: cubic-bezier(0.175, 0.885, 0.32, 1.275);
- transition-duration: 400ms;
- transform: scale(1.1, 1.1) translate3d(0, 0, 0);
- cursor: pointer;
- }
- .menu-open-button:hover {
- transform: scale(1.2, 1.2) translate3d(0, 0, 0);
- }
- .menu-open:checked + .menu-open-button {
- transition-timing-function: linear;
- transition-duration: 200ms;
- transform: scale(0.8, 0.8) translate3d(0, 0, 0);
- }
- .menu-open:checked ~ .menu-item {
- transition-timing-function: cubic-bezier(0.935, 0, 0.34, 1.33);
- }
- .menu-open:checked ~ .menu-item:nth-child(3) {
- transition-duration: 180ms;
- transform: translate3d(0.08361px, -104.99997px, 0);
- }
- .menu-open:checked ~ .menu-item:nth-child(4) {
- transition-duration: 280ms;
- transform: translate3d(90.9466px, -52.47586px, 0);
- }
- .menu-open:checked ~ .menu-item:nth-child(5) {
- transition-duration: 380ms;
- transform: translate3d(90.9466px, 52.47586px, 0);
- }
- .menu-open:checked ~ .menu-item:nth-child(6) {
- transition-duration: 480ms;
- transform: translate3d(0.08361px, 104.99997px, 0);
- }
- .menu-open:checked ~ .menu-item:nth-child(7) {
- transition-duration: 580ms;
- transform: translate3d(-90.86291px, 52.62064px, 0);
- }
- .menu-open:checked ~ .menu-item:nth-child(8) {
- transition-duration: 680ms;
- transform: translate3d(-91.03006px, -52.33095px, 0);
- }
- .menu-open:checked ~ .menu-item:nth-child(9) {
- transition-duration: 780ms;
- transform: translate3d(-0.25084px, -104.9997px, 0);
- }
- </style>
- </head>
- <!-- Everything after this cut is what actually can be seen on the page (the elements of the page), everything above is just for styling. -->
- <body>
- <!-- First Heading -->
- <h1>Gooey Menu</h1>
- <!-- Second Heading -->
- <h2>Using CSS and SVG Filters</h2>
- <!-- Third Heading -->
- <h3>
- By <a href="https://codepen.io/lbebber">Lucas Bebber</a>
- </h3>
- <!-- Fourth Heading -->
- <h4>
- <a href="https://codepen.io/lbebber/pen/LELBEo" target="_blank">
- Version 1
- </a>
- - Version 2 -
- <a href="https://codepen.io/lbebber/pen/pvwZJp" target="_blank">
- Version 3
- </a> -
- <a href="https://codepen.io/lbebber/pen/rawQKR" target="_blank">
- Version 4
- </a>
- </h4>
- <!-- Hamburger menu within the pink circle. -->
- <nav class="menu">
- <input type="checkbox" href="#" class="menu-open" name="menu-open" id="menu-open"/>
- <label class="menu-open-button" for="menu-open">
- <span class="hamburger hamburger-1"></span>
- <span class="hamburger hamburger-2"></span>
- <span class="hamburger hamburger-3"></span>
- </label>
- <!-- This is where the menu links start. -->
- <!-- Replace the '#' with the link of your choice. -->
- <!-- i.e.: <a href="#"></a> ==> <a href="/ask"></a> -->
- <!-- If you want to change the displayed icons, just change i.e.
- 'fa fa-heart' to 'fa fa-adjust' or any icon of your choice.
- -->
- <a href="#" class="menu-item"> <i class="fa fa-bar-chart"></i> </a>
- <a href="#" class="menu-item"> <i class="fa fa-plus"></i> </a>
- <a href="#" class="menu-item"> <i class="fa fa-heart"></i> </a>
- <a href="#" class="menu-item"> <i class="fa fa-envelope"></i> </a>
- <a href="#" class="menu-item"> <i class="fa fa-cog"></i> </a>
- <a href="#" class="menu-item"> <i class="fa fa-ellipsis-h"></i> </a>
- </nav>
- <!-- Filters -->
- <!-- Keep those lines.-->
- <!-- Only delete / change them if you know what you are doing. -->
- <svg xmlns="http://www.w3.org/2000/svg" version="1.1">
- <defs>
- <filter id="shadowed-goo">
- <feGaussianBlur in="SourceGraphic" result="blur" stdDeviation="10" />
- <feColorMatrix in="blur" mode="matrix" values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 18 -7" result="goo" />
- <feGaussianBlur in="goo" stdDeviation="3" result="shadow" />
- <feColorMatrix in="shadow" mode="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 -0.2" result="shadow" />
- <feOffset in="shadow" dx="1" dy="1" result="shadow" />
- <feComposite in2="shadow" in="goo" result="goo" />
- <feComposite in2="goo" in="SourceGraphic" result="mix" />
- </filter>
- <filter id="goo">
- <feGaussianBlur in="SourceGraphic" result="blur" stdDeviation="10" />
- <feColorMatrix in="blur" mode="matrix" values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 18 -7" result="goo" />
- <feComposite in2="goo" in="SourceGraphic" result="mix" />
- </filter>
- </defs>
- </svg>
- </body>
- </html>
Add Comment
Please, Sign In to add comment