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

              
                <div class="section s_06">

  <div class="accordion_one">
    <div class="accordion_header" id="ac1_b">アコーディオンの閉じるボタンを複数作る<div class="i_box"><i class="one_i"></i></div></div>
    <div class="accordion_inner">
      <div class="box_one">
        <p class="txt_a_ac">ブラウザによって閉じるボタンを押したあとの挙動が違ったので閉じた後はスクロールして上部に戻るようにしました。アコーディオンの中の内容が多いときにおすすめです。内容が少ないときは閉じるボタンは不要かなと思います。<br><br>一つ開けると他は閉じるバージョンです。</p>
      </div>
      <div class="closeArea">
        <div class="close_box"><a href="#ac1_b" 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_b">アコーディオンの閉じるボタンを複数作る<div class="i_box"><i class="one_i"></i></div></div>
    <div class="accordion_inner">
      <div class="box_one">
        <p class="txt_a_ac">ブラウザによって閉じるボタンを押したあとの挙動が違ったので閉じた後はスクロールして上部に戻るようにしました。アコーディオンの中の内容が多いときにおすすめです。内容が少ないときは閉じるボタンは不要かなと思います。<br><br>一つ開けると他は閉じるバージョンです。</p>
      </div>
      <div class="closeArea">
        <div class="close_box"><a href="#ac2_b" 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_b">アコーディオンの閉じるボタンを複数作る<div class="i_box"><i class="one_i"></i></div></div>
    <div class="accordion_inner">
      <div class="box_one">
        <p class="txt_a_ac">ブラウザによって閉じるボタンを押したあとの挙動が違ったので閉じた後はスクロールして上部に戻るようにしました。アコーディオンの中の内容が多いときにおすすめです。内容が少ないときは閉じるボタンは不要かなと思います。<br><br>一つ開けると他は閉じるバージョンです。</p>
      </div>
      <div class="closeArea">
        <div class="close_box"><a href="#ac3_b" 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_06 .accordion_one
====================================================================*/
.s_06 .accordion_one {
	max-width: 1024px;
	margin: 0 auto;
}
.s_06 .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_06 .accordion_one:nth-of-type(2) .accordion_header {
    background-color: #ff9a05;
}
.s_06 .accordion_one:nth-of-type(3) .accordion_header {
    background-color: #1c85d8;
}
.s_06 .accordion_one .accordion_header:hover {
	opacity: .8;
}
.s_06 .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_06 .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_06 .accordion_one .accordion_header.open .i_box {
	-webkit-transform: rotate(-360deg);
	transform: rotate(-360deg);
}
.s_06 .accordion_one .accordion_header .i_box .one_i:before, .s_06 .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_06 .accordion_one .accordion_header .i_box .one_i:before {
	width: 4px;
	height: 18px;
	top: 0;
	left: 7px;
}
.s_06 .accordion_one .accordion_header.open .i_box .one_i:before {
	content: none;
}
.s_06 .accordion_one .accordion_header.open .i_box .one_i:after {
	-webkit-transform: rotate(-45deg);
	transform: rotate(-45deg);
}
.s_06 .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_06 .accordion_one:nth-of-type(2) .accordion_inner {
	border-left: 2px solid #ff9a05;
	border-right: 2px solid #ff9a05;
	border-bottom: 2px solid #ff9a05;
}
.s_06 .accordion_one:nth-of-type(3) .accordion_inner {
	border-left: 2px solid #1c85d8;
	border-right: 2px solid #1c85d8;
	border-bottom: 2px solid #1c85d8;
}
.s_06 .accordion_one .accordion_inner .box_one {
	height: 300px;
}
.s_06 .accordion_one .accordion_inner p.txt_a_ac {
	margin: 0;
}
.s_06 .accordion_one .accordion_inner .closeArea {
	width: 180px;
	margin: 0 auto;
}
.s_06 .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_06 .accordion_one:nth-of-type(2) .accordion_inner .closeArea .close_box a.close_btn {
    background-color: #ff9a05;
}
.s_06 .accordion_one:nth-of-type(3) .accordion_inner .closeArea .close_box a.close_btn {
    background-color: #1c85d8;
}
.s_06 .accordion_one .accordion_inner .closeArea .close_box a.close_btn:hover {
	opacity: .8;
}
.s_06 .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_06 .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_06 .accordion_one .accordion_inner .closeArea .close_box a.close_btn .i_box .one_i:before, .s_06 .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_06 .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_06 .accordion_one .accordion_header {
		font-size: 18px;
	}
	.s_06 .accordion_one .accordion_header .i_box {
		width: 30px;
		height: 30px;
		margin-top: -15px;
	}
	.s_06 .accordion_one .accordion_inner .closeArea .close_box a.close_btn {
		font-size: 14px;
	}
}
@media screen and (max-width: 767px) {
	.s_06 .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_06 .accordion_one
$(function(){
  //.accordion_oneの中の.accordion_headerがクリックされたら
  $('.s_06 .accordion_one .accordion_header').click(function(){
    //クリックされた.accordion_oneの中の.accordion_headerに隣接する.accordion_innerが開いたり閉じたりする。
    $(this).next('.accordion_inner').slideToggle();
    $(this).toggleClass("open");
      //クリックされた.accordion_oneの中の.accordion_header以外の.accordion_oneの中の.accordion_headerに隣接する.accordion_oneの中の.accordion_innerを閉じる
    $('.s_06 .accordion_one .accordion_header').not($(this)).next('.accordion_one .accordion_inner').slideUp();
    $('.s_06 .accordion_one .accordion_header').not($(this)).removeClass("open");
  });
  //閉じるボタンがクリックされたら
  $('a.close_btn').click(function () {
    //クリックされたa.close_btnの親要素の.accordion_oneの.accordion_innerを閉じる。
    $(this).parents('.s_06 .accordion_one .accordion_inner').slideUp();
    $('.s_06 .accordion_one .accordion_header').removeClass("open");
  });
});

// ページ内リンク
$(function(){
  // 閉じるボタンをクリックした場合に処理
  $('.s_06 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