cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - Activehtmlicon-personicon-teamoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

            
              <h1>Pure CSS navigation buttons</h1>
<p>Just focus them ! (warning, some browsers don't focus on buttons, use JavaScript or another way to toggle on a real project)</p>

<div class="wrapper">

<section>
  <h2>.cross-button</h2>
  <button class="nav-button cross-button" type="button" id="toggle-button" aria-label="open/close navigation"></button>
</section>

<section>
  <h2>.arrow-button-1</h2>
  <button class="nav-button arrow-button-1" type="button" id="toggle-button" aria-label="open/close navigation"></button>
</section>

<section>
  <h2>.arrow-button-2</h2>
  <button class="nav-button arrow-button-2" type="button" id="toggle-button" aria-label="open/close navigation"></button>
</section>
  
<section>
  <h2>.arrow-button-3</h2>
  <button class="nav-button arrow-button-3" type="button" id="toggle-button" aria-label="open/close navigation"></button>
</section>

<section>
  <h2>.arrow-button-4</h2>
  <button class="nav-button arrow-button-4" type="button" id="toggle-button" aria-label="open/close navigation"></button>
</section>

<section>
  <h2>.round.button</h2>
  <button class="round-button" type="button" id="toggle-button" aria-label="open/close navigation"></button>
</section>
  
 </div>

<p>More fantastic stuffs on <a href="https://sarasoueidan.com/demos/navicon-transformicons/">https://sarasoueidan.com/demos/navicon-transformicons/</a></p>
            
          
!
            
              /* Common button styles */
.nav-button {
  position: relative;
  height: 2.4rem;
  width: 2.8rem;
  background-color: transparent;
  background-image: linear-gradient(to right, currentColor, currentColor);
  background-position: center;
  background-repeat: no-repeat;
  background-size: 100% 5px;
  padding: 0;
  outline: 0;
  border: 0;
  color: #333;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: .25s cubic-bezier(.17,.67,.89,1.4);
  transition-property: transform;
  will-change: transform;
 }
.nav-button::before,
.nav-button::after {
  content: "";
  position: absolute;
  left: 0; right: 0;
  display: block;
  height: 5px;
  background: currentColor;
  transition: .25s;
  transition-property: transform, top;
  will-change: transform, top;
}
.nav-button::before {
  top: 0;
}
.nav-button::after {
  top: calc(100% - 4px);
}



/* cross button */
.cross-button:focus {
  background-image: none;
}
.cross-button:focus::before,
.cross-button:focus::after{
   top: 50%;
 }
.cross-button:focus::before {
   transform: translate3d(0,-50%,0) rotate3d(0,0,1,45deg);
 }
.cross-button:focus::after {
   transform: translate3d(0,-50%,0) rotate3d(0,0,1,-45deg);
 }



/* arrow button 1 */
.arrow-button-1:focus {
   transform: rotate(90deg) translateZ(0);
 }
.arrow-button-1:focus::before {
  width: 60%;
  transform: rotate(-45deg) translate3d(-48%, 0, 0);
 }
.arrow-button-1:focus::after {
  width: 60%;
  transform: rotate(45deg) translate3d(-48%, 0, 0);
 }


/* arrow button 2 */
.arrow-button-2:focus {
  transform: rotate(180deg);
 }
.arrow-button-2:focus::before {
  width: 60%;
  transform: rotate(-45deg) translate3d(-48%, 0, 0);
 }
.arrow-button-2:focus::after {
  width: 60%;
  transform: rotate(45deg) translate3d(-48%, 0, 0);
 }

/* arrow button 3 */
.arrow-button-3:focus {
   transform: rotate(-90deg) translateZ(0);
 }
.arrow-button-3:focus::before {
  width: 60%;
  transform: rotate(-45deg) translate3d(-48%, 0, 0);
 }
.arrow-button-3:focus::after {
  width: 60%;
  transform: rotate(45deg) translate3d(-48%, 0, 0);
 }

/* arrow button 4 */
.arrow-button-4:focus::before {
  width: 60%;
  transform: rotate(-45deg) translate3d(-48%, 0, 0);
 }
.arrow-button-4:focus::after {
  width: 60%;
  transform: rotate(45deg) translate3d(-48%, 0, 0);
 }

/* Round button */
.round-button {
  display: inline-block;
  position: relative;
  z-index: 1;
  height: 4rem;
  width: 4rem;
  background-color: transparent;
  padding: 0;
  outline: 0;
  border: 1px solid #333;
  border-radius: 50%;
  cursor: pointer;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
  transition: transform .2s;
}
.round-button::after,
.round-button::before {
  content: "";
  position: absolute;
  top: 15%;
  right: 40%;
  bottom: 15%;
  left: 40%;
  background-color: #333;
  border-radius: 10px;
  transition: transform .25s;
  will-change: transform;
}
.round-button::before {
  top: 40%;
  right: 15%;
  bottom: 40%;
  left: 15%;
}
/* opened nav button */
.round-button:focus,
.round-button:focus::before {
  transform: rotate(90deg) translateZ(0);
}




/* Global deco */

html {
  font-size: 62.5%;
}

body {
  margin: 0;
  padding: 2rem;
  background: #222;
  color: #fff;
  font-family: helvetica, arial, sans-serif;
  font-size: 1.4em;
  line-height: 1.5;
}
.wrapper {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
}
section {
  display: inline-block;
  border: .5rem solid #000;
  vertical-align: top;
  margin-bottom: .5rem;;
  padding: 1rem 2rem 4rem;
  text-align: center;
  background: #efefef;
  flex: 1 0 25%;
}

h1,
h2 {
  margin-top: 0;
  margin-bottom: 1rem;
  
}

h1 {
  font-size: 2.8rem;
  color: #bbb;
}

h2 {
  margin-top: 2rem;
  color: #333;
}

a {
  color: #bbb
}

            
          
!
999px
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console