Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Behavior

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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta http-equiv="content-Script-Type" content="text/javascript" />
<meta http-equiv="content-Stype-Type" content="text/style" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta name="description" content="Simple Only CSS Accordion Navigation + Animation (for PC)">
<meta name="keywords" content="">
<meta name="author" content="Yorozuna" />
<title>Simple OnlyCSS Accordion Navigation + Animation (for PC)</title>
<link rel="stylesheet" href="./css/style_set.css">
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript">
// Chromeちゃんが気分次第でフォントサイズおかしくしちゃうので対処
if(navigator.userAgent.indexOf('chrome') > -1) $(function(){ document.body.style.webkitTransform = 'scale(1)'; });
</script>

<!-- いにしえのものどもと戦う -->
<!--[if lt IE 9]>
<script src="./js/html5shiv-printshiv.js"></script>
<script src="./js/IE9.js"></script>
<![endif]-->
</head>
<body>
<h1>CSSのみでアニメーションつきのアコーディオンメニュー<br>(各メニューテキスト量によって高さ自動)</h1>
<p class="ref">
  ※着想元: <a href="http://ri-mode.com/rainbow/2014/06/20/css_accordion_menu/" target="_blank">CSSだけで動きのあるアコーディオン・メニュー | Ri-mode Rainbow | No:2888</a><br>
  元記事のデモに従い、なるべくシンプルな見た目に留めてあります。<br>
  課題点とされていた高さの自由化をcssのみで実現することを試みたものです。
</p>
<nav id="menu_box">
	<ul class="menu">
	<li>
		<a href="#">メニュー1</a>
		<ul>
		<li><a href="#">1-1サブメニュー</a></li>
		<li><a href="#">1-2サブメニュー</a></li>
		</ul>
	</li>
	<li>
		<a href="#">メニュー2 ここのテキストが長くたって私、元気にやっていきます!</a>
		<ul>
		<li><a href="#">2-1サブメニュー<br>もう改行も怖くないんだから!</a></li>
		<li><a href="#">2-2サブメニュー</a></li>
		<li><a href="#">2-3サブメニュー</a></li>
		</ul>
	</li>
	<li>
		<a href="#">メニュー3</a>
		<ul>
		<li><a href="#">3-1サブメニュー</a></li>
		<li><a href="#">3-2サブメニュー</a></li>
		<li><a href="#">3-3サブメニュー</a></li>
		<li><a href="#">3-4サブメニュー</a></li>
		</ul>
	</li>
	<li>
		<a href="#">メニュー4</a>
	</li>
	</ul>
</nav>
</body>
              
            
!

CSS

              
                @charset "utf-8";

/* ---------------------------------------------
 Common Set 
--------------------------------------------- */
html {
	margin: 0;
	padding: 0;
	font-size: 62.5%;
}
html * {
	-webkit-box-sizing: border-box;
	-moz-box-sizing:    border-box;
	-o-box-sizing:      border-box;
	-ms-box-sizing:     border-box;
	box-sizing:         border-box;
}
body {
	position: relative;
	margin: 0;
	padding: 0;
	min-width: 190px;
	background-color: #fff;
	font-family: "ヒラギノ角ゴ Pro W3", "Hiragino Kaku Gothic Pro", "メイリオ", "Meiryo", "MS Pゴシック", sans-serif;
	font-size: 12px; /* rem非対応ブラウザ用 */
	font-size: 1.2rem; /* rem対応ブラウザの為に上書き指定 */
	line-height: 1.4;
	text-align: center;
	-webkit-text-size-adjust: 100%; /* Chromeちゃんが気分次第でフォントサイズおかしくしちゃうので対処 */
	color: #333;
}
a:link, a:visited, a:hover, a:active { text-decoration: underline; color: #C63; }
a:hover, a:active { text-decoration: none; }

h1 {
	margin: 20px auto 10px;
	font-size: 16px;
	font-size: 1.6rem;
}
.ref {
	margin: 0 auto 20px;
}

/* ---------------------------------------------
 Menu 
--------------------------------------------- */
.menu {
	margin: 0 auto;
	padding: 0;
	width: 190px; /* メニューの幅 */
}
.menu li {
	list-style: none;
}
.menu li a {
	display: table;
	margin-top: 1px;
	padding: 14px 10px;
	width: 100%;
	background: #337D88;
	text-decoration: none;
	text-align: left;
	vertical-align: middle;
	color: #fff;
	overflow: hidden;
		-webkit-transition-property: background;
		-webkit-transition-duration: 0.4s;
		-webkit-transition-timing-function: ease-out;
		transition-property: background;
		transition-duration: 0.4s;
		transition-timing-function: ease-out;
}
.menu > li:first-child a {
	margin-top: 0;
}
.menu li a:hover {
	background: #4AADBB;
		-webkit-transition-property: background;
		-webkit-transition-duration: 0.2s;
		-webkit-transition-timing-function: ease-out;
		transition-property: background;
		transition-duration: 0.2s;
		transition-timing-function: ease-out;
}
.menu li ul {
	margin: 0;
	padding: 0;
}
.menu li li a {
	display: block;
	margin-top: 0;
	padding: 0 10px;
	height: 0;
	background: #C6DDD9;
	color: #1F3D39;
		-webkit-transition-property: all;
		-webkit-transition-duration: 0.5s;
		-webkit-transition-timing-function: ease-out;
		transition-property: all;
		transition-duration: 0.5s;
		transition-timing-function: ease-out;
}
.menu > li:hover li a {
	display: table;
	margin-top: 1px;
	padding: 10px;
	width: 100%;
	height: 1em;
		-webkit-transition-property: all;
		-webkit-transition-duration: 0.3s;
		-webkit-transition-timing-function: ease-out;
		transition-property: all;
		transition-duration: 0.3s;
		transition-timing-function: ease-out;
}
.menu > li:hover li a:hover {
	background: #A4CAC8;
		-webkit-transition-property: background;
		-webkit-transition-duration: 0.2s;
		-webkit-transition-timing-function: ease-out;
		transition-property: background;
		transition-duration: 0.2s;
		transition-timing-function: ease-out;
}
              
            
!

JS

              
                
              
            
!
999px

Console