Pen Settings

HTML

CSS

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. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ 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

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.

HTML

              
                <head>
  <meta name="viewport" content="width=device-width,initial-scale=1.0">
  <!--==============レイアウトを制御する独自のCSSを読み込み===============-->
  <link rel="stylesheet" type="text/css" href="https://assets.codepen.io/6329135/reset.css">
  <!--ツールチップ出現用のアニメーションを指定するCSS。読み込まなくてもフェードインで出現します。-->
  <link rel="stylesheet" type="text/css" href="https://unpkg.com/tippy.js@5.0.3/animations/shift-toward-subtle.css">
  <!--ツールチップの色を指定するCSS。読み込まなくても黒色で出現します。-->
  <link rel="stylesheet" type="text/css" href="https://unpkg.com/tippy.js@5.0.3/themes/light-border.css">
</head>

<body>

  <p class="caption">文章が続く中で<span class="cap" data-tippy-content="キャプションが入ります。">この文章にカーソルを合わせると</span>ツールチップが出ます</p>

  <button class="btn cap" data-tippy-content="<div class='inner-cap'><p>続きは会員登録をしたら読むことができます。</p><p>ツールチップにはHTMLも使えます。</p></div>">ボタン</button>

  <p class="caption">使用したライブラリ:<a href="https://atomiks.github.io/tippyjs/" target="_blank">https://atomiks.github.io/tippyjs</a></p>

</body>
<!--ツールチップを出すためのJS-->
<script src="https://unpkg.com/popper.js@1"></script>
<script src="https://unpkg.com/tippy.js@5"></script>
</script>
</body>
              
            
!

CSS

              
                @charset "UTF-8";

/*========= レイアウトのためのCSS ===============*/

body {
  width: 100%;
  height: 100vh;
  vertical-align: middle;
  padding: 10px 30px;

  /*背景画像設定*/
  background: url("https://assets.codepen.io/6329135/img_04.jpg") no-repeat
    center;
  background-size: cover;
}

p.caption {
  text-align: center;
  margin: 100px 0;
  font-size: 1.2rem;
  color: #fff;
  text-shadow: 1px 1px 2px #333;
}

.inner-cap p {
  font-size: 0.8rem;
  color: #333;
}

.btn {
  display: block;
  outline: none;
  color: #fff;
  width: 200px;
  border-radius: 10px;
  padding: 10px 50px;
  margin: 0 auto;
  /*背景の色と形状*/
  background: linear-gradient(
    270deg,
    #3bade3 0%,
    #576fe6 25%,
    #9844b7 51%,
    #ff357f 100%
  );
  text-shadow: 1px 1px 2px #333;
}

.btn:hover {
  transform: scale(0.9);
}

span {
  background: linear-gradient(transparent 60%, #ffff66 60%);
  cursor: pointer; /*カーソルを指マークに変更*/
}

a {
  color: #333;
}

a:hover {
  text-decoration: none;
}

              
            
!

JS

              
                tippy(".cap", {
  //指定した要素にツールチップが出現
  placement: "top-start", //ツールチップの表示位置⇒top、top-start、top-end、right、right-start、right-end、bottom、bottom-start、bottom-end、left、left-start、left-end。指定をしなくてもtopに表示
  animation: "shift-toward-subtle", //ツールチップ出現の動き。動きを指定するにはhttps://unpkg.com/browse/tippy.js@5.0.3/animations/から任意の動きを選び<head>内に読み込むことが必要。使用できる動き⇒shift-away、shift-away-subtle、shift-away-extreme、shift-toward、shift-toward-subtle、shift-toward-extreme、scale、scale-subtle、scale-extreme、perspective、perspective-subtle、perspective-extreme。指定をしなくてもfadeで表示
  theme: "light-border", //ツールチップのテーマの色。色を指定するにはhttps://unpkg.com/browse/tippy.js@5.0.3/themes/からテーマを選び<head>内に読み込んで指定する。テーマの種類⇒light、light-border、material、translucent。指定をしなくても黒色で表示
  duration: 700 //ツールチップの出現の速さをミリ秒単位で指定
});

              
            
!
999px

Console