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 is required to process package imports. If you need a different preprocessor remove all packages first.

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

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

              
                <html lang="ja" dir="ltr">
<head>
<meta charset="utf-8" />
<title>♡キュンキュンボタン サンプル</title>
<meta name="viewport" content="width=640px" />
</head>
<body>

<header>
<h1 class="siteTitle"><img src="https://tom2rd.sakura.ne.jp/hanakotech/wp-content/uploads/2019/08/1566312472n8jfm2ul10Ao5nQ1566312427-3.gif" alt="小平あたりでCivicTech" /></h1>
</header>
  

  
<p class="backEntry"><a href="https://tom2rd.sakura.ne.jp/hanakotech">小平あたりでCivicTech</a></p>

<h1 class="entry-title">HTML5 バージョン キュンキュン♡ボタン サンプル</h1>

</article>

<!-- ↓ここからサンプル↓ -->
<div class="sample">

<!-- ↓へぇボタンの HTML↓ -->
<form>
<div id="renge">
<p><input type="range" name="hee" id="hee" min="0" max="20" value="0" /></p>
</div>
<label for="hee" class="btn-love"></label>
</form>
<!-- ↑へぇボタンの HTML↑ -->

<div class="audio">
<audio src="https://tom2rd.sakura.ne.jp/hanakotech/kyun/audio/hee.mp3" id="heeAudio" controls="controls"><p>audio 要素に対応したブラウザでは「へぇ」の音声ファイルの再生が可能です。</p></audio>
</div>

</div>



<!-- ↑ここまでサンプル↑ -->

</body>
</html>
              
            
!

CSS

              
                

/* ここはメニューには直接関係ない基本スタイル */
body {
background: #fff;
color: #333;
font-family: sans-serif;
font-size: small;
line-height: 1.5;
margin: 0;
padding: 0;
}

a {
color: #22aacc;
text-decoration: underline;
}

a:visited {
color: #009999;
}

a:hover,
a:active {
color: #ff3366;
text-decoration: underline;
}

.siteTitle {
background: #000;
font-size: 1em;
height: 120px;
margin: 0;
overflow: hidden;
padding: 10px;
text-align: center;
}

.backEntry {
background: #eee;
border: 1px solid #ccc;
border-radius: 10px;
margin: 1em auto;
padding: 2px 0;
text-align: center;
width: 15em;
}

.backEntry a {
display: block;
}

article {
padding: 0 1em 50px;
}

h1 {
font-size: 1em;
}

.entry-title {
font-size: 1.2em;
}

.sample {
border: 1px solid #ddd;
margin: 0 auto 30px;
padding: 20px;
width: 300px;
}

.sample form {
margin-bottom: 50px;
text-align: center;
}

/* ↓ここからへぇボタン関連のスタイル↓ */

.sample #hee {
height: 300px;
margin: 0;
padding: 0;
-webkit-transform: rotate(-90deg);
transform: rotate(-90deg);
width: 300px;
}

.sample #renge {
background: url(https://tom2rd.sakura.ne.jp/hanakotech/kyun/img/range_back_light.png) no-repeat center bottom;
height: 300px;
margin: 0;
padding: 0;
}

.sample #renge p {
background: url(https://tom2rd.sakura.ne.jp/hanakotech/kyun/img/renge_back.png) no-repeat center bottom;
height: 300px;
margin: 0;
padding: 0;
}

.sample label {
display: block;
padding-top: 50px;
}

/* へぇ数ごとの設定 */
.sample #renge.hee0 {
background-position: center 300px;
}

.sample #renge.hee1 {
background-position: center 285px;
}

.sample #renge.hee2 {
background-position: center 270px;
}

.sample #renge.hee3 {
background-position: center 255px;
}

.sample #renge.hee4 {
background-position: center 240px;
}

.sample #renge.hee5 {
background-position: center 225px;
}

.sample #renge.hee6 {
background-position: center 210px;
}

.sample #renge.hee7 {
background-position: center 195px;
}

.sample #renge.hee8 {
background-position: center 180px;
}

.sample #renge.hee9 {
background-position: center 165px;
}

.sample #renge.hee10 {
background-position: center 150px;
}

.sample #renge.hee11 {
background-position: center 135px;
}

.sample #renge.hee12 {
background-position: center 120px;
}

.sample #renge.hee13 {
background-position: center 105px;
}

.sample #renge.hee14 {
background-position: center 90px;
}

.sample #renge.hee15 {
background-position: center 75px;
}

.sample #renge.hee16 {
background-position: center 60px;
}

.sample #renge.hee17 {
background-position: center 45px;
}

.sample #renge.hee18 {
background-position: center 30px;
}

.sample #renge.hee19 {
background-position: center 15px;
}

.sample #renge.hee20 {
background-position: center bottom;
}
body {
  text-align: center;
}

h1 {
  text-align: center;
  color: #555;
  font-weight: normal;
}

#btn {
  position: fixed;
  //left: -100%;
  //top: -100%;
  opacity: 0;
  z-index: -1;
}

.btn-love {
  position: absolute;
  z-index: -1;
  left: 0;
  right: 0;
  top: 60vh;
  margin: auto;
  //height: 100%;
  width: 100%;
  cursor: pointer;
  transform: scale(2);
  &:after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 100px;
    margin: 0 auto;
    background: url(https://abs.twimg.com/a/1446862637/img/t1/web_heart_animation.png) 0 0 no-repeat;
    background-size: 2900%;
    height: 100px;
    width: 100px;
  }
}

#btn:checked + .btn-love:after {
  animation: heart-burst steps(28) .8s 1 both ;
}

.btn-love:after {
  animation: heart-burst steps(28) .8s both infinite;
}

@keyframes heart-burst {
  0% {
    background-position: left;
  }

  100% {
    background-position: right;
  }
}

              
            
!

JS

              
                // へぇボタンを押す度の処理
$(function(){
  // 最初にゲージを0にして、音声ファイルを読み込み
  $("#renge").addClass("hee0");
  var audio = $("#heeAudio")[0];
  // へぇボタンクリックごとの処理
  $("label").click(function () {
    // 押す度に range の value を 1ずつ増加させる
    num = parseInt($("#hee").val());
    add = 1;
    $("#hee").val(num + add);
    // 音声の再生
    audio.load();
    audio.play();
    // class の付与
    numC = $("#hee").val();
    cls = "hee" + numC;
    $("#renge").removeClass().addClass(cls);
  });
});
              
            
!
999px

Console