Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

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

              
                	<div class="example">
		<dl class="navAccordion_sample">
			<dt><button type="button" aria-controls="panel-01" aria-expanded="true">たぬき屋</button></dt>
			<dd id="panel-01" aria-hidden="false">
				<p>岡山市を代表するうどん屋。店舗は東古松と北長瀬にあり、いつも賑わう地元の繁盛店である。特徴は何と言っても麺。圧力釜で素早く茹で上がるその麺は、しなやかさと柔らかさの向こうにしっかりとした弾力が感じられる極上のモチモチ麺である。僅かながら北長瀬店の方が出汁の酸味が強く感じられる。</p>
			</dd>
			<dt><button type="button" aria-controls="panel-02" aria-expanded="true">うどん村</button></dt>
			<dd id="panel-02" aria-hidden="false">
				<p>たぬき屋が岡山うどんの代表格であるなら、うどん村は讃岐うどんの代表格。店舗は奥田本町と辰巳にあり、こちらも賑わっている。麺は太くゴリゴリの男麺。冷やした麺は、食べ終わると顎が疲れるほど。讃岐ならではのイリコ出汁は、つい飲み干してしまいそうになる。ただ辰巳店が出来た頃から手打ちをやめてしまったらしく、表面のざらつきがなくなりツルっとした麺は好みが分かれるところ。</p>
			</dd>
			<dt><button type="button" aria-controls="panel-03" aria-expanded="true">栄楽うどん</button></dt>
			<dd id="panel-03" aria-hidden="false">
				<p>倉敷市役所近くの人気店。暖簾に「讃岐の手打」と書いてはあるが、厳密には讃岐うどんではない。なか浦系と呼ばれる店の中で最も太く強いコシの麺と、透明で何味なのかよく分からない出汁の組み合わせは絶妙。メニューに無い「スペシャル」を頼むことが常連客のステイタスであり、さらに上級者は肉うどんの肉を生のままビニール袋で持ち帰るらしい。</p>
			</dd>
		</dl>
	</div>
              
            
!

CSS

              
                body {
	background: #f4f4f4;
	font-size: 18px;
	font-family: sans-serif;
}
button {
	border: none;
	appearance: none;
	font-size: 18px;
}
.example {
	padding: 10px;
	background: #FFF;
	margin: 20px auto;
	width:60%;
}
.navAccordion_sample{
	&>dt{
		&>button{
			background: #007788;
			border-top: 1px solid #FFF;
			position: relative;
			padding: 10px 20px;
			color: #FFF;
			text-align: left;
			cursor: pointer;
			width: 100%;
			&:hover,&:focus{
				background: #005566;	
			}
			&::after{
				position: absolute;
				top: 0.5em;
				right: 10px;
				content: "\02228";				
			}
			&[aria-expanded="true"]{
				&::after{
					content: "\02227";					
				}
			}
		}
		&:first-child{
			&>button{
				border-top: none;
			}
		}
	}
	&>dd{
		background: #FFF;
		color: #333;
		padding: 20px;
		&[aria-hidden="true"]{
			display: none;
		}
	}
}
              
            
!

JS

              
                $(function(){
	var flg = 0;
	$('.navAccordion_sample > dd').attr('aria-hidden',true);
	$('.navAccordion_sample > dt > button').attr('aria-expanded',false);
	$('.navAccordion_sample > dt > button').on('click activate',function(){
		if( flg ) return false;
		flg = 1;
		var state = $(this).attr('aria-expanded') === 'false' ? true : false;
		$(this).attr('aria-expanded',state);
		$(this).parent().next().slideToggle(function(){
			flg = 0;
		});
   		$(this).parent().next().attr('aria-hidden',!state);
		return false;
	});
	$('.navAccordion_sample > dt > button').on('keydown',function(event){
		var keyCode = event.keyCode || e.which;
		if (keyCode === 13){
			$(this).trigger('activate');
		}
	});
});
              
            
!
999px

Console