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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

              
                <p>令和まであと…?</p>

<p class="counter"></p>

              
            
!

CSS

              
                body {
  text-align: center;
  background: #eee;
  padding: 20px;
}

.counter {
  font-size: 2em;
  background: #fff;
  display: inline-block;
  padding: 20px;
  border-radius: 10px;
  border: 1px solid #ccc;
}
              
            
!

JS

              
                //オブジェクト取得
const reiwa = document.querySelector('.reiwa');
const counter = document.querySelector('.counter');

//あと何日メソッド
function nanNichi(){

//今の日時
const d1 = new Date();
//ターゲット日時
const d2 = new Date('2019/05/01 00:00'); //令和元年
//時差(ミリ秒)
const d3 = d2 - d1;
// ミリ秒から秒に
const d3_Sec = Math.floor(d3 / 1000);

//分、時、日の秒数
const Minute_Sec = 60;
const Hour_Sec = 60 * 60;
const Day_Sec = 60 * 60 * 24;

//あと何日  
const d4_Day = Math.floor(d3_Sec / Day_Sec);

//あと何時間
const d5_Hour = Math.floor(d3_Sec / Hour_Sec  % 24);

//あと何分
const d6_Minute = Math.floor(d3_Sec / Minute_Sec % 60);

//あと何秒
const d7_Sec = Math.floor(d3_Sec % 60);
   
//カウントダウン
counter.innerHTML = d4_Day + "日" + d5_Hour + "時間" + d6_Minute + "分" + d7_Sec + "秒!!";

//1秒ごとに実行
setTimeout(nanNichi, 1000);
}

//関数実行
nanNichi();
              
            
!
999px

Console