cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-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>A pure CSS onclick menu</h1>
<div tabindex="0" class="onclick-menu">
    <ul class="onclick-menu-content">
        <li><button onclick="alert('click 1')">Look, mom</button></li>
        <li><button onclick="alert('click 2')">no JavaScript!</button></li>
        <li><button onclick="alert('click 3')">Pretty nice, right?</button></li>
              /* The necessities */
.onclick-menu {
	position: relative;
	display: inline-block;
.onclick-menu:before {
	content: "Click me!";
.onclick-menu:focus {
	pointer-events: none;

.onclick-menu:focus .onclick-menu-content {
	opacity: 1;
	visibility: visible;

.onclick-menu-content {
	pointer-events: auto;
	position: absolute;
	z-index: 1;

	opacity: 0;
	visibility: hidden;
	transition: visibility 0.5s;

.onclick-menu.no-pointer-events {
	pointer-events: auto !important;

.onclick-menu.no-visibility .onclick-menu-content {
	visibility: visible !important;
	display: none;

.onclick-menu.no-visibility:focus .onclick-menu-content {
	display: block;

.onclick-menu.no-opacity .onclick-menu-content {
	opacity: 1 !important;

Eye candy 
( colors courtesy of https://kuler.adobe.com/try-color-theme-3350110 )
.onclick-menu {
	padding: 0;
	margin: 0 0 1em 0;
	outline: 0;
.onclick-menu:before {
	padding: 5px 10px;
	background-color: #94a4a5;
.onclick-menu-content {
	background-color: #364656;
	width: auto;

	margin-top: 19px;
	margin-left: 0;
	padding: 10px;

/* arrow for the expanding part */
.onclick-menu-content:before {
	content: "";
	width: 0;
	height: 0;

	border-bottom: 10px solid #364656;
	border-left: 10px solid transparent;
	border-right: 10px solid transparent;

	position: absolute;
	top: -10px;

.onclick-menu-content li {
	color: #f2f5e9;
	list-style-type: none;
	white-space: nowrap;

/* style the buttons */
.onclick-menu-content button {
	background: transparent;
	border: none;
	color: inherit;
	cursor: inherit;
	outline: 0;
	cursor: pointer;
.onclick-menu-content button:hover {
	color: #ff8c31;

/* Codepen stuff */
body {
  text-align: center;
  font-family: Arial, sans-serif;
.onclick-menu {

  text-align: left;
h1 {
  color: #c0c0c0;
  margin-top: 5%;
  font-weight: 400;
              // http://koen.kivits.com/articles/pure-css-menu/

// (doesn't work on iOS Safari)

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.


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