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

              
                .spotlight
.container
  h1 CSS Spotlight
  p background:radial-gradient() の円形グラデーションでスポットライトを形成。
  p JSでグラデーションの中心をカーソルに合わせている。
  p グラデーションのレイヤー(.spotlight)自体を移動させてしまうと調整が大変なため、 radial-gradient() の中心を移動させる手法にしている。
  h2 想定される用法
  p ビジュアル演出のほか初回アクセス時のチュートリアルなどに使える。
  p チュートリアル利用時はカーソル追従はさせず、注目点に直接当てる形が好ましい。
              
            
!

CSS

              
                body {
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue";
}
.container {
  width: 70vw;
  margin: 20px auto;
}
.spotlight {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  //background: rgba(#000,.4);
  background: radial-gradient(
    50px 50px //サイズ
    at //お約束
    center center,//位置
    transparent, //中央
    transparent 100px, //中央〜ボカシ
    rgba(#000,.6) 150px//ボカシ〜外周
  );
  opacity: 0;
  animation: fadein 2s 1s 1 both;
}

//animation
@keyframes fadein {
  0% {opacity: 0;}
  100% {opacity: 1;}
}


              
            
!

JS

              
                //レイヤーを移動させると手間が大きいので
//グラデーションの中央を移動させる
$(document).mousemove(function(e){
  $('.spotlight').attr({  'style':'background:radial-gradient(50px 50px at '+ e.clientX +'px '+ e.clientY +'px, transparent, transparent 100px, rgba(0,0,0,0.6) 150px)'
  });
});

              
            
!
999px

Console