cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

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. 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.

Quick-add: + add another resource

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.

Quick-add: + add another resource

Code Indentation

     

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.

            
              <body>
<div class="mv">
      <div class="obj"></div>
    </div>
    <div class="attention"><p>SCROLL</p></div>
    <div class="dummy_height"></div>
</body>
            
          
!
            
              * {
        box-sizing: border-box;
      }
      body, html {
        width: 100%;
        height: 100%;
        margin: 0;
        padding: 0;
      }
      .mv {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        overflow: hidden;
        background-color: #1b2920;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
      }
      .obj {
        width: 70%;
        height: 70%;
      }
      .dummy_height {
        position: absolute;
        top:5000px;
        width: 1px;
        height: 1px;
      }
      .attention {
        position: fixed;
        width: 100%;
        height: 100%;
        color: #FFF;
        font-weight: bold;
        font-size: 18px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: flex-end;
        letter-spacing: 0.05em;
      }
            
          
!
            
              

init();


// 初期設定
function init() {
}


// 毎フレーム実行
window.requestAnimationFrame(update);
function update() {

  // ステージサイズ
  var sw = window.innerWidth;
  var sh = window.innerHeight;

  // スクロール位置
  var scroll = $(window).scrollTop();

  // スクロール進捗率 0 ~ 1
  var scrollP = scroll / ($(document).height() - sh);

  // 下に行くにつれ色が変わる
  $('.mv > .obj').css({
    backgroundColor:chroma.mix(0x7fb6a2, 0xc13d23, scrollP).css()
  });

  window.requestAnimationFrame(update);
}








// ----------------------------------------
// 度からラジアンに変換
// @val : 度
// ----------------------------------------
function radian(val) {
  return val * Math.PI / 180;
}

// ----------------------------------------
// ラジアンから度に変換
// @val : ラジアン
// ----------------------------------------
function degree(val) {
  return val * 180 / Math.PI;
}

// ----------------------------------------
// minからmaxまでランダム
// ----------------------------------------
function random(min, max) {
  return Math.random() * (max - min) + min;
}

// ----------------------------------------
// 範囲変換
// @val     : 変換したい値
// @toMin   : 変換後の最小値
// @toMax   : 変換後の最大値
// @fromMin : 変換前の最小値
// @fromMax : 変換前の最大値
// ----------------------------------------
function map(val, toMin, toMax, fromMin, fromMax) {
  if(val <= fromMin) {
    return toMin;
  }
  if(val >= fromMax) {
    return toMax;
  }
  p = (toMax - toMin) / (fromMax - fromMin);
  return ((val - fromMin) * p) + toMin;
}

            
          
!
999px
Loading ..................

Console