Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's 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 it's URL and the proper URL extention.

+ add another resource


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


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.


Save Automatically?

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.


                <div class="content">
  <header class="header">
    <h1 class="header__ttl">Close Btn</h1>
  <div class="space"></div>
  <div id="a-hide" class="hide-floating">
    <h2 class="hide-floating__ttl">ここで消える</h2>
    <div class="hide-floating__content"></div>
  <div id="floatingBtn" class="floating">
    <a class="floating__btn"></a>
    <div id="floatingClose" class="floating__close">x</div>


                * {
  margin: 0;
  padding: 0;

  font-family: 'Helvetica Neue', Arial, 'Hiragino Kaku Gothic Pro N', Meiryo, sans-serif;

a:hover {
  cursor: pointer;

.content {
  margin: 0 auto;
  max-width: 600px;
  position: relative;

.header {
  align-items: center;
  display: flex;
  height: 80px;
  padding: 0 20px;
  &__ttl {
    font-size: 24px;
    font-weight: bold;

.space {
  background: #f7f7f7;
  height: 100vh;

.hide-floating {
  &__ttl {
    font-size: 24px;
    font-weight: bold;
    text-align: center;
    padding: 20px 0;
  &__content {
    background: #5ABEDC;
    height: 100vh;

.floating {
  bottom: 25px;
  position: fixed;
  right: 25px;
  z-index: 100;
  &__btn {
    background: #00466E;
    display: block;
    height: 80px;
    text-align: center;
    width: 300px;
  &__close {
    color: #fff;
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 999;


                const closeBtn = $('#floatingClose');
const FloatingBtn = $('#floatingBtn');

// 閉じるボタンを押したかどうか。
let closeClicked = false;

closeBtn.on('click', () => {
  closeClicked = true;

$(window).on('scroll', function() {
  let scrollY = $(this).scrollTop();
  const hide = $('#a-hide');
  const hideY = hide.offset().top;
  const hideHeight = hide.outerHeight();
  const hidePos = hideY - hideHeight;

  if (scrollY > hidePos) {
  } else if (!closeClicked) { // 閉じるボタンを押していない場合のみフェードイン