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

              
                <section>
  <div class="area">
    <div class="title">【jQuery】<br>スクロールして、指定した場所から出てきて、指定した場所で消える、実装サンプル</div>
    <p class="_a"><a href="https://125naroom.com/web/4582" target="_blank" class="link">View the note</a></p>
  </div>
  <div class="area" id="start">
    <div class="title">しかくが出てきますよ</div>
  </div>
  <div class="area">
    <div class="title">出てますね</div>
  </div>
  <div class="area" id="end">
    <div class="title">しかくが消えますよ</div>
  </div>
  <div class="area">
    <div class="title">消えてますね</div>
  </div>
</section>

<div class="sikaku_box">しかく</div>
              
            
!

CSS

              
                /*================
.sikaku_box
================*/

.sikaku_box {
	position: fixed;
	right: 0;
	bottom: 0;
  display: flex;
	justify-content: center;
	align-items: center;
	width: 100px;
	height: 100px;
	background: #fff689;
  box-sizing: border-box;
	font-size: 16px;
	font-weight: bold;
  opacity: 0;
	z-index: -1;
	transition: 0.3s;
}
.sikaku_box.fixed {
	opacity: 1;
	z-index: 9;
}

/*================
以下は不要です。
================*/

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;
	}
}
.area {
	height: 1000px;
	background: #ccc;
}
section .area:nth-child(even) {
	background: #fff;
}
.title {
	font-size: 30px;
	font-weight: bold;
}
@media screen and (max-width: 1024px) {
	.title {
		font-size: 18px;
	}
}
p._a {
	font-size: 12px;
	font-weight: bold;
	margin: 30px 0 0;
}
p._a .link {
	display: inline-block;
	color: #607D8B;
	padding-left: 1.3em;
	text-indent: -1.3em;
}
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 () {
  $(window).on('load scroll', function () { //スクロールするよ
    var scrollHeight = $(document).height(); //ページ上部からの距離を取得
    var scrollPosition = $(window).height() + $(window).scrollTop(); //Windowの高さを取得+スクロール位置を取得
    var startHeight = $("#start").innerHeight(); //場所指定(ここでは出てくる場所)
    var endHeight = $("#end").innerHeight(); //場所指定(ここでは消える場所)
    if (startHeight <= $(this).scrollTop()) { //スクロール距離が『#start』を超えたら
      $('.sikaku_box').addClass('fixed'); //fixedというclassを追加
      if (scrollHeight - scrollPosition <= endHeight) { //スクロール距離が『#end』を超えたら
        $('.sikaku_box').removeClass('fixed'); //fixedというclassを削除
      } else {
        $('.sikaku_box').addClass('fixed'); //fixedというclassを追加
      }
    } else {
      $('.sikaku_box').removeClass('fixed'); //fixedというclassを削除
    }
  });
});
              
            
!
999px

Console