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">
  <div class="box_area">
    <p>IDは<span id="idNumber">a1234</span>です。</p>
    <button id="copyBtn">IDをコピーする</button>
  </div>
  <p class="_a"><a href="https://125naroom.com/web/3037" target="_blank" class="link">View the note</a></p>
</div>
              
            
!

CSS

              
                .box_area {
  border: 2px solid #333;
  padding: 30px;
}
.box_area p {
  font-size: 18px;
  font-weight: bold;
  margin: 0 0 20px;
}
.box_area p span {
  color: #db0f2f;
  padding: 0 7px;
}
.box_area button {
  font-size: 14px;
  font-weight: bold;
  text-align: center;
  text-decoration: none;
  background: #fff;
  box-sizing: border-box;
  -webkit-appearance: none;
  -webkit-border-radius: 0;
  border-radius: 0;
  transition-duration: 0.2s;
  cursor: pointer;
  border: 2px solid #333;
  padding: 5px 12px;
}
.box_area button:hover {
  color: #fff;
  background: #333;
}
/*====================================================================
以下は不要です。
====================================================================*/
body, button {
  font-family: YuGothic, "游ゴシック体", "Yu Gothic", "ヒラギノ角ゴ Pro", "Hiragino Kaku Gothic Pro", "メイリオ", Meiryo, "MS Pゴシック", "MS PGothic", sans-serif;
  letter-spacing: .025em;
  line-height: 1.8;
  margin: 0;
}
.section {
  max-width: 280px;
  margin: 20px auto;
}
.section p._a {
  font-size: 12px;
  font-weight: bold;
  padding: 0;
}
.section p._a .link {
  position: relative;
  display: inline-block;
  padding-left: 12px;
  margin: 0;
  color: #607D8B;
}
.section p._a .link:before {
  content: '';
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 6px 0 6px 8px;
  border-color: transparent transparent transparent #607D8B;
  position: absolute;
  top: 50%;
  left: 0;
  margin-top: -6px;
}
              
            
!

JS

              
                var button = document.getElementById('copyBtn');
button.addEventListener('click', function(){
  // コピー対象を変数として定義する
  var idNumber = document.getElementById('idNumber');
  var range = document.createRange();
  range.selectNode(idNumber);
  window.getSelection().addRange(range);
  // IDをクリップボードにコピーする
  document.execCommand('copy');
  // コピー完了をお知らせする
  alert('IDをコピーしました');
});
              
            
!
999px

Console