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 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

Looking for quick-add? Try the external resource search, it's quicker and gives you access to the most recent version of thousands of libraries. ☝️

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Looking for quick-add? Try the external resource search, it's quicker and gives you access to the most recent version of thousands of libraries. ☝️

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

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.

            
              <section class="content_accordion section">
				<header class="section_index">
					<h2>accordion</h2>
				</header>
				<div class="section_content">
					<dl class="content_accordion_child" data-accordion="open">
						<dt class="content_accordion_child_index">
							見出し1
							<span class="content_accordion_child_indexCap close">close</span>
							<span class="content_accordion_child_indexCap open">open</span>													
						</dt>
						<dd class="content_accordion_child_content" >
							 <p>アコーディオン1のコンテンツアコーディオン1のコンテンツ<br>アコーディオン1のコンテンツ</p>
						</dd>
					</dl>
					<dl class="content_accordion_child close" data-accordion="close">
						<dt class="content_accordion_child_index">
							見出し2
							<span class="content_accordion_child_indexCap close">close</span>
							<span class="content_accordion_child_indexCap open">open</span>													
						</dt>
						<dd class="content_accordion_child_content" >
							 <p>アコーディオン2のコンテンツアコーディオン2のコンテンツ<br>アコーディオン2のコンテンツ</p>
						</dd>
					</dl>
					<dl class="content_accordion_child close" data-accordion="close">
						<dt class="content_accordion_child_index">
							見出し3
							<span class="content_accordion_child_indexCap close">close</span>
							<span class="content_accordion_child_indexCap open">open</span>							
						</dt>
						<dd class="content_accordion_child_content" >
							 <p>アコーディオン3のコンテンツアコーディオン3のコンテンツ<br>アコーディオン3のコンテンツ</p>
						</dd>
					</dl>
				</div>
			</section>

	<script type="text/javascript" src="http://satohmsys.info/files/demo/tweenmax/site/js/tweenmax/minified/TweenMax.min.js"></script>
            
          
!
            
              @import url(https://fonts.googleapis.com/css?family=Pacifico);
body, html {
  padding: 0;
  margin: 0;
}

html {
  position: relative;
  border-top: solid 5px #121212;
  line-height: 1.6;
}

img {
  line-height: 1;
  max-width: 100%;
  height: auto;
  outline: 0;
}

ul {
  margin: 0;
  padding: 0;
}

.content_accordion .section_index {
  display: table;
  text-align: center;
  white-space: nowrap;
}
.content_accordion .section_index:after, .content_accordion .section_index:before {
  content: '';
  display: table-cell;
  width: 50%;
  background: linear-gradient(rgba(0, 0, 0, 0) 50%, currentColor 50%, currentColor calc(50% + 1px), rgba(0, 0, 0, 0) calc(50% + 1px));
  background-clip: padding-box;
}
.content_accordion .section_index:after {
  border-left: 1em solid transparent;
}
.content_accordion .section_index:before {
  border-right: 1em solid transparent;
}
.content_accordion .section_index {
  font-size: 1em;
  font-weight: normal;
}
.content_accordion .section_content {
  display: -webkit-flex;
  display: -ms-flexbox;
  display: flex;
  -webkit-justify-content: space-around;
      -ms-flex-pack: distribute;
          justify-content: space-around;
  -webkit-align-content: start;
      -ms-flex-line-pack: start;
          align-content: start;
}
.content_accordion_child {
  -webkit-flex-basis: 30%;
      -ms-flex-preferred-size: 30%;
          flex-basis: 30%;
}
.content_accordion_child.close .content_accordion_child_content {
  height: 0;
  display: none;
}
.content_accordion_child_index, .content_accordion_child_content p {
  padding: 1em;
}
.content_accordion_child_index {
  line-height: 1;
  position: relative;
  text-align: center;
  background-color: #eee;
}
.content_accordion_child_indexCap {
  height: 1em;
  margin: auto;
  padding: 0.5em;
  cursor: pointer;
  transition: all 0.5s;
  opacity: 1;
  position: absolute;
  top: 0;
  right: 5px;
  bottom: 0;
  font-size: 0.6em;
  color: #fff;
  border-radius: 3px;
  background-color: #999;
}
.content_accordion_child_indexCap.open {
  background-color: #666;
}
.content_accordion_child_content {
  border: solid 1px #eee;
  margin-left: 0;
}
.content_accordion [data-accordion="open"] .open {
  opacity: 0;
}
.content_accordion [data-accordion="open"] .close {
  opacity: 1;
}
.content_accordion [data-accordion="close"] .open {
  opacity: 1;
}
.content_accordion [data-accordion="close"] .close {
  opacity: 0;
}
@media screen and (max-width: 600px) {
  .content_accordion .section_content {
    -webkit-flex-direction: column;
        -ms-flex-direction: column;
            flex-direction: column;
  }
}
            
          
!
            
              var getByClass = function( cls, num ){
	if( typeof num == "number" ){
		classCollection = document.getElementsByClassName( cls )[num];
	} else {
		classCollection = document.getElementsByClassName( cls );
		classCollection.length == 1 ? classCollection = classCollection[0] : '';

	}
	return classCollection;
};

$accordion = getByClass( 'content_accordion_child' ),
$accordion_tab = getByClass( 'content_accordion_child_index' ),
$TimelineMax = new TimelineMax();


/**
* アコーディオン
*/

Array.prototype.forEach.call( $accordion, function( e, index ){
	var $index =  e.getElementsByClassName( 'content_accordion_child_index' );

	$index[0].addEventListener( 'click', function( e ){
		var $text = e.target;
		
		if( /indexCap/.test( $text.className ) ){
			$parent = $text.parentNode,
			$dd = $parent.nextElementSibling,
			$dtHeight = $parent.clientHeight;
		} else {
			$dd = $text.nextElementSibling,
			$dtHeight = $text.clientHeight;
		}
		$dl = $dd.parentNode,
		$status = $dl.getAttribute('data-accordion');

		//open時=閉じる
		if( $status == 'open' ){		
			$TimelineMax.fromTo( $dd, 0.5, {
				overflow: 'hidden',
			},
			{
				height: 0,
				display: 'none',
				ease:Back.easeIn,
				onComplete: function( ){
					$dl.setAttribute( 'data-accordion', 'close' );
				}
			});
		} else {
			//close時=開く
			
			$TimelineMax.fromTo( $dd, 1, {
				display: 'block',
				overflow: 'hidden'
			},
			{
				height: '80%',
				delay: 0.5,
				ease:Bounce.easeOut,
				onComplete: function(){
					$dl.setAttribute( 'data-accordion', 'open' );
				}
			});		
		}
		
	} );
} );
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console