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

              
                
  
  
  <!-- JavaScript -->
  <script src="https://code.jquery.com/jquery-3.6.0.js"></script>
  
</head>
<body>
<section class="sample">
    <div class="sample__bg"></div>
    <!--Section-->
    <div class="sample__container sample__container--flex inner">
      <!--Left-->
      <div class="sample__chapter">
        <h2 class="sample__ttl">
          目次
        </h2>
        <div class="sample__head">タイトルが入る</div>
        <!--クリック後動作-->
        <a href="#1" class="sample__tab js-sample__tab-circle">見出し1</a>
        <a href="#2" class="sample__tab">見出し2</a>
      </div>
      <!--Right-->
      <div class="sample__wrapper">
        <div class="sample__description">
          ダミーテキストダミーテキストダミーテキストダミーテキストダミーテキストダミーテキストダミーテキストダミーテキストダミーテキスト
        </div>
        <!--見出し / セクション-->
        <div class="sample__article">
          <!--本文-->
          <div id="1" class="sample__contents">
            <h3 class="sample__article__head">見出し1</h3>
            <p>親譲りの無鉄砲で小供の時から損ばかりしている。小学校に居る時分学校の二階から飛び降りて一週間ほど腰を抜かした事がある。なぜそんな無闇をしたと聞く人があるかも知れぬ。別段深い理由でもない。新築の二階から</p>
                        <p>親譲りの無鉄砲で小供の時から損ばかりしている。小学校に居る時分学校の二階から飛び降りて一週間ほど腰を抜かした事がある。なぜそんな無闇をしたと聞く人があるかも知れぬ。別段深い理由でもない。新築の二階から</p>
                        <p>親譲りの無鉄砲で小供の時から損ばかりしている。小学校に居る時分学校の二階から飛び降りて一週間ほど腰を抜かした事がある。なぜそんな無闇をしたと聞く人があるかも知れぬ。別段深い理由でもない。新築の二階から</p>
                        <p>親譲りの無鉄砲で小供の時から損ばかりしている。小学校に居る時分学校の二階から飛び降りて一週間ほど腰を抜かした事がある。なぜそんな無闇をしたと聞く人があるかも知れぬ。別段深い理由でもない。新築の二階から</p>
                        <p>親譲りの無鉄砲で小供の時から損ばかりしている。小学校に居る時分学校の二階から飛び降りて一週間ほど腰を抜かした事がある。なぜそんな無闇をしたと聞く人があるかも知れぬ。別段深い理由でもない。新築の二階から</p>
          </div>
          <!--見出し-->
          <div id="2" class="sample__contents">
            <h3 class="sample__article__head">見出し2</h3>
           <p>親譲りの無鉄砲で小供の時から損ばかりしている。小学校に居る時分学校の二階から飛び降りて一週間ほど腰を抜かした事がある。なぜそんな無闇をしたと聞く人があるかも知れぬ。別段深い理由でもない。新築の二階から</p>
                        <p>親譲りの無鉄砲で小供の時から損ばかりしている。小学校に居る時分学校の二階から飛び降りて一週間ほど腰を抜かした事がある。なぜそんな無闇をしたと聞く人があるかも知れぬ。別段深い理由でもない。新築の二階から</p>
                        <p>親譲りの無鉄砲で小供の時から損ばかりしている。小学校に居る時分学校の二階から飛び降りて一週間ほど腰を抜かした事がある。なぜそんな無闇をしたと聞く人があるかも知れぬ。別段深い理由でもない。新築の二階から</p>
                        <p>親譲りの無鉄砲で小供の時から損ばかりしている。小学校に居る時分学校の二階から飛び降りて一週間ほど腰を抜かした事がある。なぜそんな無闇をしたと聞く人があるかも知れぬ。別段深い理由でもない。新築の二階から</p>
                        <p>親譲りの無鉄砲で小供の時から損ばかりしている。小学校に居る時分学校の二階から飛び降りて一週間ほど腰を抜かした事がある。なぜそんな無闇をしたと聞く人があるかも知れぬ。別段深い理由でもない。新築の二階から</p>
          </div>
        </div>
        <!--Right-->
      </div>
      <!--sample__wrapper-->
    </div>
    <!--sample__container--flex-->
    <!--2つ目-->
    <!--Section-->
    <div class="sample__container--white">
      <div class="sample__container sample__container--flex inner">
        <!--Left-->
        <div class="sample__chapter">
          <h2 class="sample__ttl">
            目次2
          </h2>
          <div class="sample__head">タイトルが入るよ</div>
          <!--クリック後動作-->
          <a href="#3" class="sample__tab js-sample__tab-circle">見出し3</a>
          <a href="#4" class="sample__tab">見出し4</a>
          <a href="#5" class="sample__tab">見出し5</a>
        </div>
        <!--Right-->
        <div class="sample__wrapper">
          <!--見出し / セクション-->
          <div class="sample__article">
            <!--本文-->
            <div id="3" class="sample__contents">
              <h3 class="sample__article__head">見出し3</h3>
              <p>親譲りの無鉄砲で小供の時から損ばかりしている。小学校に居る時分学校の二階から飛び降りて一週間ほど腰を抜かした事がある。なぜそんな無闇をしたと聞く人があるかも知れぬ。別段深い理由でもない。新築の二階から</p>
                        <p>親譲りの無鉄砲で小供の時から損ばかりしている。小学校に居る時分学校の二階から飛び降りて一週間ほど腰を抜かした事がある。なぜそんな無闇をしたと聞く人があるかも知れぬ。別段深い理由でもない。新築の二階から</p>
                        <p>親譲りの無鉄砲で小供の時から損ばかりしている。小学校に居る時分学校の二階から飛び降りて一週間ほど腰を抜かした事がある。なぜそんな無闇をしたと聞く人があるかも知れぬ。別段深い理由でもない。新築の二階から</p>
                        <p>親譲りの無鉄砲で小供の時から損ばかりしている。小学校に居る時分学校の二階から飛び降りて一週間ほど腰を抜かした事がある。なぜそんな無闇をしたと聞く人があるかも知れぬ。別段深い理由でもない。新築の二階から</p>
                        <p>親譲りの無鉄砲で小供の時から損ばかりしている。小学校に居る時分学校の二階から飛び降りて一週間ほど腰を抜かした事がある。なぜそんな無闇をしたと聞く人があるかも知れぬ。別段深い理由でもない。新築の二階から</p>
            </div>
            <!--sample__contents-->
            <div id="4" class="sample__contents">
              <h3 class="sample__article__head"> 見出し4 </h3>
             <p>親譲りの無鉄砲で小供の時から損ばかりしている。小学校に居る時分学校の二階から飛び降りて一週間ほど腰を抜かした事がある。なぜそんな無闇をしたと聞く人があるかも知れぬ。別段深い理由でもない。新築の二階から</p>
                        <p>親譲りの無鉄砲で小供の時から損ばかりしている。小学校に居る時分学校の二階から飛び降りて一週間ほど腰を抜かした事がある。なぜそんな無闇をしたと聞く人があるかも知れぬ。別段深い理由でもない。新築の二階から</p>
                        <p>親譲りの無鉄砲で小供の時から損ばかりしている。小学校に居る時分学校の二階から飛び降りて一週間ほど腰を抜かした事がある。なぜそんな無闇をしたと聞く人があるかも知れぬ。別段深い理由でもない。新築の二階から</p>
                        <p>親譲りの無鉄砲で小供の時から損ばかりしている。小学校に居る時分学校の二階から飛び降りて一週間ほど腰を抜かした事がある。なぜそんな無闇をしたと聞く人があるかも知れぬ。別段深い理由でもない。新築の二階から</p>
                        <p>親譲りの無鉄砲で小供の時から損ばかりしている。小学校に居る時分学校の二階から飛び降りて一週間ほど腰を抜かした事がある。なぜそんな無闇をしたと聞く人があるかも知れぬ。別段深い理由でもない。新築の二階から</p>
            </div>
            <!--sample__contents-->
            <div id="5" class="sample__contents">
              <h3 class="sample__article__head"> 見出し5</h3>
              <p>親譲りの無鉄砲で小供の時から損ばかりしている。小学校に居る時分学校の二階から飛び降りて一週間ほど腰を抜かした事がある。なぜそんな無闇をしたと聞く人があるかも知れぬ。別段深い理由でもない。新築の二階から</p>
                        <p>親譲りの無鉄砲で小供の時から損ばかりしている。小学校に居る時分学校の二階から飛び降りて一週間ほど腰を抜かした事がある。なぜそんな無闇をしたと聞く人があるかも知れぬ。別段深い理由でもない。新築の二階から</p>
                        <p>親譲りの無鉄砲で小供の時から損ばかりしている。小学校に居る時分学校の二階から飛び降りて一週間ほど腰を抜かした事がある。なぜそんな無闇をしたと聞く人があるかも知れぬ。別段深い理由でもない。新築の二階から</p>
                        <p>親譲りの無鉄砲で小供の時から損ばかりしている。小学校に居る時分学校の二階から飛び降りて一週間ほど腰を抜かした事がある。なぜそんな無闇をしたと聞く人があるかも知れぬ。別段深い理由でもない。新築の二階から</p>
                        <p>親譲りの無鉄砲で小供の時から損ばかりしている。小学校に居る時分学校の二階から飛び降りて一週間ほど腰を抜かした事がある。なぜそんな無闇をしたと聞く人があるかも知れぬ。別段深い理由でもない。新築の二階から</p>
            </div>
            <!--sample__contents-->
          </div>
          <!--sample__article-->
        </div>
        <!--sample__wrapper-->
      </div>
      <!--sample__container-->
    </div>
  </section>
  </body
  </html>
              
            
!

CSS

              
                
/*=====
# 共通化パーツ
============*/
img {
  display: block;
  width: 100%;
  height: auto;
}

a {
  cursor: pointer;
  text-decoration: none;
}

/*=======
# 共通化
==================*/
body {
  font-family: "YuGothic", "游ゴシック", "ヒラギノ角ゴ ProN W3", "Hiragino Kaku Gothic ProN", "メイリオ", Meiryo, "Droid Sans", sans-serif;
  line-height: 1.6;
  font-weight: 400;
  color: #333;
}

.inner {
  width: 100%;
  max-width: 1400px;
  padding-right: 40px;
  padding-left: 40px;
  margin-right: auto;
  margin-left: auto;
}
@media screen and (max-width: 600px) {
  .inner {
    padding-right: 20px;
    padding-left: 20px;
  }
}

.sample__container {
  padding-top: 110px;
  padding-bottom: 44px;
}

.sample__container:last-child {
  padding-bottom: 120px;
}

.sample__container--flex {
  display: flex;
}
@media screen and (max-width: 768px) {
  .sample__container--flex {
    display: block;
  }
}

.sample__chapter {
  width: 35%;
  height: 100%;
  position: -webkit-sticky;
  position: sticky;
  top: 20px;
}
@media screen and (max-width: 768px) {
  .sample__chapter {
    width: 100%;
    position: static;
  }
}

.sample__head {
  font-family: "YuGothic";
  font-weight: bold;
  font-size: 31px;
  line-height: 47px;
  padding-bottom: 36px;
}

.sample__tab {
  display: block;
  font-size: 16px;
  font-weight: bold;
  margin-bottom: 16px;
  position: relative;
  padding-left: 1.5em;
}

.sample__wrapper {
  width: 65%;
}
@media screen and (max-width: 768px) {
  .sample__wrapper {
    width: 100%;
  }
}

.sample__description {
  font-family: "YuGothic";
  font-style: normal;
  font-weight: 700;
  font-size: 22px;
  padding-bottom: 48px;
}
@media screen and (max-width: 768px) {
  .sample__description {
    padding-top: 32px;
    padding-bottom: 32px;
  }
}

.sample__catch {
  font-family: "YuGothic";
  padding-bottom: 72px;
}
@media screen and (max-width: 768px) {
  .sample__catch {
    padding-bottom: 32px;
  }
}

.sample__catch__lead {
  font-size: 16px;
}

.sample__catch__lead span {
  font-weight: 700;
  color: #003070;
  display: inline-block;
  padding-right: 16px;
  padding-bottom: 12px;
}

.sample__contents {
  border-top: 1px solid #adadad;
  padding-top: 24px;
  padding-bottom: 36px;
}

.sample__article__head {
  font-family: "YuGothic";
  padding: 0px 0.7em;
  font-size: 22px;
  color: #003070;
  border-left: solid 10px #bda913;
  margin-top: 16px;
  margin-bottom: 36px;
}

.sample__contents p {
  font-family: "YuGothic";
  font-weight: 500;
  font-size: 16px;
  letter-spacing: 0.03em;
  color: #333333;
  padding-bottom: 24px;
}

.sample__container--white {
  background: #f9f9f9;
}



.sample {
}
.sample__bg {
    width: 100%;
    background: url(../images/brings_bg.png);
    background-position: top left;
    background-repeat: no-repeat;
    background-size: contain;
    height: 500px;
    position: absolute;
    z-index: -1;
    top: 111px;
}
.sample__container {
    padding-top: 110px;
    padding-bottom: 44px;
}
.sample__container:last-child{
    padding-bottom: 120px;
}
.sample__container--flex {
    display: flex;

    @include mq(md) {
        display: block;
    }
}
.sample__chapter {
    width: 35%;
    height: 100%;
    position: sticky;
    top: 20px;
    @include mq(md) {
        width: 100%;
        position: static;
    }
}
.sample__head {
    font-family: "YuGothic";
    font-weight: bold;
    font-size: 31px;
    line-height: 47px;
    padding-bottom: 36px;
}
.sample__tab {
    display: block;
    font-size: 16px;
    font-weight: bold;
    margin-bottom: 16px;
    position: relative;
    padding-left: 1.5em; //24px
}

.js-sample__tab-circle:before {
    position: absolute;
    display: block;
    content: "";
    width: 12px;
    height: 12px;
    background-color: #003070;
    border-radius: 50%;
    top: 50%;
    left: 0;
    transform: translateY(-50%);
    transition: all 0.3s ease 0s;
}

////Right//////
.sample__wrapper {
    width: 65%;
    @include mq(md) {
        width: 100%;
    }
}
.sample__description {
    font-family: "YuGothic";
    font-style: normal;
    font-weight: 700;
    font-size: 22px;
    padding-bottom: 48px;
    @include mq(md) {
        padding-top: 32px;
        padding-bottom: 32px;
    }
}
.sample__catch {
    font-family: "YuGothic";
    padding-bottom: 72px;
    @include mq(md) {
        padding-bottom: 32px;
    }
}
.sample__catch__lead {
    font-size: 16px;
}
.sample__catch__lead span {
    font-weight: 700;
    color: #003070;
    display: inline-block;
    padding-right: 16px;
    padding-bottom: 12px;
}

.sample__article {
}
.sample__contents {
    border-top: 1px solid #adadad;
    padding-top: 24px;
    padding-bottom: 36px;
}

.sample__article__head {
    font-family: "YuGothic";
    padding: 0px 0.7em;
    font-size: 22px;
    color: #003070;
    border-left: solid 10px #003070;
    margin-top: 16px;
    margin-bottom: 36px;
}
.sample__contents p {
    font-family: "YuGothic";
    font-weight: 500;
    font-size: 16px;
    letter-spacing: 0.03em;
    color: #333333;
    padding-bottom: 24px;
}

.sample__container--white {
    background: #f9f9f9;
}
              
            
!

JS

              
                jQuery(function ($) {
  // この中であればWordpressでも「$」が使用可能になる

  //グローバルナビのアクティブ表示
  $(function () {
    let scrollPoint = function () {
      let array = {
        "#1": 0,
        "#2": 0,
        "#3": 0,
        "#4": 0,
        "#5": 0
      };
      let $toc = new Array();

      for (var key in array) {
        if ($(key).offset()) {
          array[key] = $(key).offset().top - 50;
          $toc[key] = $('.sample .sample__chapter a[href="' + key + '"]');
        }
      }

      $(window).scroll(function () {
        for (var key in array) {
          if ($(window).scrollTop() > array[key] - 50) {
            $(".sample .sample__chapter a").each(function () {
              $(this).removeClass("js-sample__tab-circle");
            });
            $toc[key].addClass("js-sample__tab-circle");
          }
        }
      });
    };
    // 実行
    scrollPoint();
  });

  // この上であればWordpressでも「$」が使用可能になる
});

              
            
!
999px

Console