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="table_area">
  <div class="prompt"><!--促すメッセージtable_outerの直前に記入-->
    <div>スクロールが出来ます
      <span class="flash_box">→</span>
      <span class="flash_box display_none"><br>↓</span>
    </div>
  </div>
  <div class="table_outer"><!--スクロールするテーブルのアウターjsでclassを指定-->
    <div class="inner">
      <table>
        <tr>
          <th class="fixed title">固定タイトル</th>
          <th>タイトル1</th>
          <th>タイトル2</th>
          <th>タイトル3</th>
          <th>タイトル4</th>
          <th>タイトル5</th>
          <th>タイトル6</th>
          <th>タイトル7</th>
          <th>タイトル8</th>
          <th>タイトル9</th>
          <th>タイトル10</th>
          <th>タイトル11</th>
          <th>タイトル12</th>
          <th class="last">タイトル13</th>
        </tr>
        <tr>
          <td class="fixed">固定タイトル</td>
          <td>セル1</td>
          <td>セル2</td>
          <td>セル3</td>
          <td>セル4</td>
          <td>セル5</td>
          <td>セル6</td>
          <td>セル7</td>
          <td>セル8</td>
          <td>セル9</td>
          <td>セル10</td>
          <td>セル11</td>
          <td>セル12</td>
          <td>セル13</td>
        </tr>
        <tr>
          <td class="fixed">固定タイトル</td>
          <td>セル1</td>
          <td>セル2</td>
          <td>セル3</td>
          <td>セル4</td>
          <td>セル5</td>
          <td>セル6</td>
          <td>セル7</td>
          <td>セル8</td>
          <td>セル9</td>
          <td>セル10</td>
          <td>セル11</td>
          <td>セル12</td>
          <td>セル13</td>
        </tr>
        <tr>
          <td class="fixed">固定タイトル</td>
          <td>セル1</td>
          <td>セル2</td>
          <td>セル3</td>
          <td>セル4</td>
          <td>セル5</td>
          <td>セル6</td>
          <td>セル7</td>
          <td>セル8</td>
          <td>セル9</td>
          <td>セル10</td>
          <td>セル11</td>
          <td>セル12</td>
          <td>セル13</td>
        </tr>
        <tr>
          <td class="fixed">固定タイトル</td>
          <td>セル1</td>
          <td>セル2</td>
          <td>セル3</td>
          <td>セル4</td>
          <td>セル5</td>
          <td>セル6</td>
          <td>セル7</td>
          <td>セル8</td>
          <td>セル9</td>
          <td>セル10</td>
          <td>セル11</td>
          <td>セル12</td>
          <td>セル13</td>
        </tr>
        <tr>
          <td class="fixed">固定タイトル</td>
          <td>セル1</td>
          <td>セル2</td>
          <td>セル3</td>
          <td>セル4</td>
          <td>セル5</td>
          <td>セル6</td>
          <td>セル7</td>
          <td>セル8</td>
          <td>セル9</td>
          <td>セル10</td>
          <td>セル11</td>
          <td>セル12</td>
          <td>セル13</td>
        </tr>
        <tr>
          <td class="fixed">固定タイトル</td>
          <td>セル1</td>
          <td>セル2</td>
          <td>セル3</td>
          <td>セル4</td>
          <td>セル5</td>
          <td>セル6</td>
          <td>セル7</td>
          <td>セル8</td>
          <td>セル9</td>
          <td>セル10</td>
          <td>セル11</td>
          <td>セル12</td>
          <td>セル13</td>
        </tr>
      </table>
    </div>
  </div>
</div>
              
            
!

CSS

              
                /*スクロールさせるためのアウター設定*/
.table_area{
  width: 60%;
  margin:3rem auto;
  position: relative;/*スクロールするテーブルの大枠に設定*/
}
/*■ここからテーブルの設定(必要によって変更)■*/
.table_outer{
  overflow-x: auto;
  scrollbar-color: #0070C0 #e0e0e0;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
  padding: 0 0 0.5rem;
}
.table_outer::-webkit-scrollbar {
  width: 5px;
  height: 10px;
  border-radius: 5px;
}
.table_outer::-webkit-scrollbar-track {
  background-color: rgba(0, 0, 0, 0.1);
  border-radius: 5px;
}
.table_outer::-webkit-scrollbar-thumb {
  box-shadow: inset 0 0 10px rgba(0, 112, 192, 1);
  border-radius: 5px;
}
.table_outer .inner{
  width:auto;
}
.table_outer table{
		width: 100%;
}
tr{
  border-right: 2px #000 solid;
}
th{
  color: #FFF;
  background-color: #000;
  text-align: center;
  border: transparent;
  border-right: 1px #FFF solid;
  padding: 0.2rem 0.5rem;
  white-space: nowrap;
}
th.last{
  border-right: 1px #000 solid;
}
td{
  text-align: center;
  white-space: nowrap;
  background-color: #FFF;
  padding: 0.2rem 1rem;
  border: 1px solid #000;
  border-top: 2px #000 solid;
  vertical-align: middle;
}
/*テーブルの固定セル設定*/
.fixed{
  position: sticky;
  left: 0;
}
.fixed:before{
  content: "";
  position: absolute;
  border-left:1px solid #000;
  top: -1px;
  left: -1px;
  width: 100%;
  height: calc(100% + 1px);
}
.fixed::after{
  content: "";
  position: absolute;
  height: 100%;
  width: 1px;
  right: -1px;
  top: 0;
  background: #000;
}
.fixed.title::after{
  background: #FFF;
}
/*■ここまでテーブルの設定■*/
/*スクロールを促すボックス*/
.prompt{
  position: absolute;
  top:3rem;
  left: 50%;
	transform: translateX(-50%);
  color:#FFF;
  background: rgba(0,0,0,0.5);
	border-radius: 0.5rem;
	text-align: center;
	vertical-align: middle;
	padding: 1rem;
  z-index:3;
}
.prompt div{
  white-space: nowrap;
}
/*共通設定*/
.flex_area{
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-justify-content: center;
  justify-content: center;
  -webkit-align-items: center;
  align-items: center;
  -webkit-align-content: center;
  align-content: center;
  -webkit-align-self: center;
  align-self: center;
  flex-wrap: wrap;
}
.fadeout {
  animation: fadeout-keyframes 1s ease 0s 1 forwards;
}
@keyframes fadeout-keyframes {
  0% {
    opacity: 1;
  }

  100% {
    opacity: 0;
  }
}
.fadein {
  animation: fadein-keyframes 1s ease 0s 1 forwards;
}
@keyframes fadein-keyframes {
  0% {
    opacity: 0;
  }

  100% {
    opacity: 1;
  }
}
.flash_box{
  animation: flash 1s linear infinite;
}
@keyframes flash {
  0%,100% {
    opacity: 1;
  }

  50% {
    opacity: 0;
  }
}
.display_none{
  display:none
}
              
            
!

JS

              
                let elements = document.getElementsByClassName('table_outer');
  let len = elements.length;
  for (let i = 0; i < len; i++){
    target = elements.item(i);
    target.onscroll = function(){
      let y = target.scrollLeft;
      let x = target.scrollTop;
      if(y > 5 || x > 5){
        target.previousElementSibling.classList.remove("fadein");
        target.previousElementSibling.classList.add("fadeout");
      }else if(y == 0 && x == 0){//戻った時に再出現させたくない時は削除
        target.previousElementSibling.classList.add("fadein");
        target.previousElementSibling.classList.remove("fadeout");
      }
    }
  }
              
            
!
999px

Console