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_03">
<h2 id="s_03">jQueryのページ内リンクのスクロール(位置を50px下にずらす)</h2>

  <ul>
    <li><a href="#s_03_1">1</a></li>
    <li><a href="#s_03_2">2</a></li>
    <li><a href="#s_03_3">3</a></li>
    <li><a href="#s_03_4">4</a></li>
    <li><a href="#s_03_5">5</a></li>
    <li><a href="#s_03_6">6</a></li>
  </ul>

  <div class="oneArea" id="s_03_1">
    <div class="one_title">1</div>
    <a class="button" href="#s_03">▲ メニューに戻る</a>
  </div>

  <div class="oneArea" id="s_03_2">
    <div class="one_title">2</div>
    <a class="button" href="#s_03">▲ メニューに戻る</a>
  </div>

  <div class="oneArea" id="s_03_3">
    <div class="one_title">3</div>
    <a class="button" href="#s_03">▲ メニューに戻る</a>
  </div>

  <div class="oneArea" id="s_03_4">
    <div class="one_title">4</div>
    <a class="button" href="#s_03">▲ メニューに戻る</a>
  </div>

  <div class="oneArea" id="s_03_5">
    <div class="one_title">5</div>
    <a class="button" href="#s_03">▲ メニューに戻る</a>
  </div>

  <div class="oneArea" id="s_03_6">
    <div class="one_title">6</div>
    <a class="button" href="#s_03">▲ メニューに戻る</a>
  </div>

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

CSS

              
                .section .oneArea {
	margin-bottom: 200px;
}
.section ul {
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	list-style-type: none;
	margin: 0 0 100px;
	padding: 0;
	box-sizing: border-box;
}
.section ul li {
	width: calc(100% / 6);
	border-right: 1px solid #fff;
	text-align: center;
	box-sizing: border-box;
}
.section ul li:last-child {
	border-right: none;
}
.section ul li a {
	display: block;
	padding: 10px;
	text-decoration: none;
	color: #fff;
	background: #333;
	transition-duration: 0.3s;
}
.section ul li a:hover {
	opacity: 0.7;
}
.section .oneArea .one_title {
	color: #fff;
	text-align: center;
	padding: 10px;
	background: #333;
}
.section .oneArea a.button {
	display: block;
	font-size: 12px;
	color: #333333;
	text-align: center;
	background: #f2f2f2;
	padding: 10px;
	text-decoration: none;
	transition-duration: 0.3s;
	margin-top: 40px;
}
.section .oneArea a.button:hover {
	opacity: 0.7;
}
@media screen and (max-width: 1024px) {
	.section .oneArea .one_title {
		font-size: 18px;
	}
}
/*====================================================================
以下は不要です。
====================================================================*/
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

              
                $(function(){
  // #で始まるアンカーをクリックした場合に処理
  $('.s_03 a[href^="#"]').click(function(){
    // 移動先を50px下にずらす
    var adjust = 50;
    // スクロールの速度
    var speed = 400; // ミリ秒
    // アンカーの値取得
    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