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="section s_05">

  <div class="accordion_one">
    <div class="accordion_header" id="ac1">アコーディオンの閉じるボタンを複数作る<div class="i_box"><i class="one_i"></i></div></div>
    <div class="accordion_inner">
      <div class="box_one">
        <p class="txt_a_ac">ブラウザによって閉じるボタンを押したあとの挙動が違ったので閉じた後はスクロールして上部に戻るようにしました。アコーディオンの中の内容が多いときにおすすめです。内容が少ないときは閉じるボタンは不要かなと思います。</p>
      </div>
      <div class="closeArea">
        <div class="close_box"><a href="#ac1" class="close_btn">閉じる<div class="i_box"><i class="one_i"></i></div></a></div>
      </div>
    </div>
  </div>
  
  <div class="accordion_one">
    <div class="accordion_header" id="ac2">アコーディオンの閉じるボタンを複数作る<div class="i_box"><i class="one_i"></i></div></div>
    <div class="accordion_inner">
      <div class="box_one">
        <p class="txt_a_ac">ブラウザによって閉じるボタンを押したあとの挙動が違ったので閉じた後はスクロールして上部に戻るようにしました。アコーディオンの中の内容が多いときにおすすめです。内容が少ないときは閉じるボタンは不要かなと思います。</p>
      </div>
      <div class="closeArea">
        <div class="close_box"><a href="#ac2" class="close_btn">閉じる<div class="i_box"><i class="one_i"></i></div></a></div>
      </div>
    </div>
  </div>
  
  <div class="accordion_one">
    <div class="accordion_header" id="ac3">アコーディオンの閉じるボタンを複数作る<div class="i_box"><i class="one_i"></i></div></div>
    <div class="accordion_inner">
      <div class="box_one">
        <p class="txt_a_ac">ブラウザによって閉じるボタンを押したあとの挙動が違ったので閉じた後はスクロールして上部に戻るようにしました。アコーディオンの中の内容が多いときにおすすめです。内容が少ないときは閉じるボタンは不要かなと思います。</p>
      </div>
      <div class="closeArea">
        <div class="close_box"><a href="#ac3" class="close_btn">閉じる<div class="i_box"><i class="one_i"></i></div></a></div>
      </div>
    </div>
  </div>

  <p class="_a"><a href="https://125naroom.com/web/3046" target="_blank" class="link">View the note</a></p>
</div>
              
            
!

CSS

              
                /*====================================================================
.s_05 .accordion_one
====================================================================*/
.s_05 .accordion_one {
	max-width: 1024px;
	margin: 0 auto;
}
.s_05 .accordion_one .accordion_header {
	background-color: #db0f2f;
	color: #fff;
	font-size: 26px;
	font-weight: bold;
	padding: 20px 11%;
	text-align: center;
	position: relative;
	z-index: +1;
	cursor: pointer;
	transition-duration: 0.2s;
}
.s_05 .accordion_one:nth-of-type(2) .accordion_header {
    background-color: #ff9a05;
}
.s_05 .accordion_one:nth-of-type(3) .accordion_header {
    background-color: #1c85d8;
}
.s_05 .accordion_one .accordion_header:hover {
	opacity: .8;
}
.s_05 .accordion_one .accordion_header .i_box {
	display: flex;
	justify-content: center;
	align-items: center;
	position: absolute;
	top: 50%;
	right: 5%;
	width: 40px;
	height: 40px;
	border: 1px solid #fff;
	margin-top: -20px;
	box-sizing: border-box;
	-webkit-transform: rotate(45deg);
	transform: rotate(45deg);
	transform-origin: center center;
	transition-duration: 0.2s;
}
.s_05 .accordion_one .accordion_header .i_box .one_i {
	display: block;
	width: 18px;
	height: 18px;
	-webkit-transform: rotate(45deg);
	transform: rotate(45deg);
	transform-origin: center center;
	transition-duration: 0.2s;
	position: relative;
}
.s_05 .accordion_one .accordion_header.open .i_box {
	-webkit-transform: rotate(-360deg);
	transform: rotate(-360deg);
}
.s_05 .accordion_one .accordion_header .i_box .one_i:before, .s_05 .accordion_one .accordion_header .i_box .one_i:after {
	display: flex;
	content: '';
	background-color: #fff;
	border-radius: 10px;
	width: 18px;
	height: 4px;
	position: absolute;
	top: 7px;
	left: 0;
	-webkit-transform: rotate(0deg);
	transform: rotate(0deg);
	transform-origin: center center;
}
.s_05 .accordion_one .accordion_header .i_box .one_i:before {
	width: 4px;
	height: 18px;
	top: 0;
	left: 7px;
}
.s_05 .accordion_one .accordion_header.open .i_box .one_i:before {
	content: none;
}
.s_05 .accordion_one .accordion_header.open .i_box .one_i:after {
	-webkit-transform: rotate(-45deg);
	transform: rotate(-45deg);
}
.s_05 .accordion_one .accordion_inner {
	display: none;
	padding: 30px 30px;
	border-left: 2px solid #db0f2f;
	border-right: 2px solid #db0f2f;
	border-bottom: 2px solid #db0f2f;
	box-sizing: border-box;
}
.s_05 .accordion_one:nth-of-type(2) .accordion_inner {
	border-left: 2px solid #ff9a05;
	border-right: 2px solid #ff9a05;
	border-bottom: 2px solid #ff9a05;
}
.s_05 .accordion_one:nth-of-type(3) .accordion_inner {
	border-left: 2px solid #1c85d8;
	border-right: 2px solid #1c85d8;
	border-bottom: 2px solid #1c85d8;
}
.s_05 .accordion_one .accordion_inner .box_one {
	height: 300px;
}
.s_05 .accordion_one .accordion_inner p.txt_a_ac {
	margin: 0;
}
.s_05 .accordion_one .accordion_inner .closeArea {
	width: 180px;
	margin: 0 auto;
}
.s_05 .accordion_one .accordion_inner .closeArea .close_box a.close_btn {
	display: flex;
	justify-content: center;
	align-items: center;
	background: #db0f2f;
	padding: 15px 15px 15px 20px;
	text-decoration: none;
	line-height: 1.3;
	color: #fff;
	font-size: 18px;
	font-weight: bold;
	position: relative;
	cursor: pointer;
	transition-duration: 0.2s;
}
.s_05 .accordion_one:nth-of-type(2) .accordion_inner .closeArea .close_box a.close_btn {
    background-color: #ff9a05;
}
.s_05 .accordion_one:nth-of-type(3) .accordion_inner .closeArea .close_box a.close_btn {
    background-color: #1c85d8;
}
.s_05 .accordion_one .accordion_inner .closeArea .close_box a.close_btn:hover {
	opacity: .8;
}
.s_05 .accordion_one .accordion_inner .closeArea .close_box a.close_btn .i_box {
	display: flex;
	justify-content: center;
	align-items: center;
	position: absolute;
	top: 50%;
	left: 10%;
	width: 30px;
	height: 30px;
	margin-top: -15px;
}
.s_05 .accordion_one .accordion_inner .closeArea .close_box a.close_btn .i_box .one_i {
	display: flex;
	justify-content: center;
	align-items: center;
	position: relative;
	width: 18px;
	height: 18px;
}
.s_05 .accordion_one .accordion_inner .closeArea .close_box a.close_btn .i_box .one_i:before, .s_05 .accordion_one .accordion_inner .closeArea .close_box a.close_btn .i_box .one_i:after {
	content: '';
	background-color: #fff;
	border-radius: 10px;
	width: 18px;
	height: 4px;
	position: absolute;
	top: 7px;
	left: 0;
	-webkit-transform: rotate(-45deg);
	transform: rotate(45deg);
	transform-origin: center center;
}
.s_05 .accordion_one .accordion_inner .closeArea .close_box a.close_btn .i_box .one_i:before {
	width: 4px;
	height: 18px;
	top: 0;
	left: 7px;
}
@media screen and (max-width: 1024px) {
	.s_05 .accordion_one .accordion_header {
		font-size: 18px;
	}
	.s_05 .accordion_one .accordion_header .i_box {
		width: 30px;
		height: 30px;
		margin-top: -15px;
	}
	.s_05 .accordion_one .accordion_inner .closeArea .close_box a.close_btn {
		font-size: 14px;
	}
}
@media screen and (max-width: 767px) {
	.s_05 .accordion_one .accordion_header {
		font-size: 16px;
		text-align: left;
		padding: 15px 60px 15px 15px;
	}
}

/*====================================================================
以下は不要です。
====================================================================*/

body {
	font-family: YuGothic, "游ゴシック体", "Yu Gothic", "ヒラギノ角ゴ Pro", "Hiragino Kaku Gothic Pro", "メイリオ", Meiryo, "MS Pゴシック", "MS PGothic", sans-serif;
	font-size: 16px;
	letter-spacing: .025em;
	line-height: 1.8;
	margin: 0;
}
@media screen and (max-width: 1024px) {
	body {
		font-size: 14px;
	}
}
.section {
	max-width: 1024px;
	margin: 0 auto;
	padding: 20px 20px 500px;
}
.section p._a {
	font-size: 12px;
	font-weight: bold;
	margin: 30px 0 0;
}
.section p._a .link {
	display: inline-block;
	color: #607D8B;
	padding-left: 1.3em;
	text-indent: -1.3em;
}
.section p._a .link:before {
	content: '';
	display: inline-block;
	width: 5px;
	height: 5px;
	border-top: 2px solid #607D8B;
	border-right: 2px solid #607D8B;
	-webkit-transform: rotate(45deg);
	transform: rotate(45deg);
	margin-right: 10px;
}
              
            
!

JS

              
                // .s_05 .accordion_one
$(function(){
  //.accordion_oneの中の.accordion_headerがクリックされたら
  $('.s_05 .accordion_one .accordion_header').click(function(){
    //クリックされた.accordion_oneの中の.accordion_headerに隣接する.accordion_innerが開いたり閉じたりする。
    $(this).next('.accordion_inner').slideToggle();
    $(this).toggleClass("open");
  });
  //閉じるボタンがクリックされたら
  $('a.close_btn').click(function () {
    //クリックされたa.close_btnの親要素.accordion_innerを閉じる。
    $(this).parents('.accordion_inner').slideUp();
    //クリックされたa.close_btnの親要素.accordion_innerの前要素にクラスopenがなければ追加し、あれば削除する。
    $(this).parents('.accordion_inner').prev().toggleClass("open");
  });
});

// ページ内リンク
$(function(){
  // 閉じるボタンをクリックした場合に処理
  $('.s_05 a.close_btn').click(function() {
    // 移動先を0px上にずらす
    var adjust = 0;
    // スクロールの速度
    var speed = 500; // ミリ秒
    // アンカーの値取得
    var href= $(this).attr("href");
    // 移動先を取得
    var target = $(href == "#" || href == "" ? 'html' : href);
    // 移動先を調整
    var position = target.offset().top - adjust;
    // スムーススクロール
    $('body,html').animate({scrollTop:position}, speed, 'swing');
    return false;
  });
});
              
            
!
999px

Console