0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

javascript演習 2日目、3日目/30日

Posted at

覚えたことたち

1秒ごとに1度回転させる

const now = new Date();

const seconds = now.getSeconds();
const secondsDegree = ((seconds / 60) * 360);
secondHand.style.transform = `rotate(${secondsDegree}deg)`;

ーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーー

ドキュメントのルート要素にcssの変数を設定する

:root {
  --base: #ffc600;
  --spacing: 10px;
  --blur: 10px;
}

img {
   padding: var(--spacing);
   background: var(--base);
   filter: blur(var(--blur));
}

javascriptでhtmlタグのアトリビュートを操作する

//<audio data-key="80">とかのタグをdata-keyで絞り込む
const audio = document.querySelector(`audio[data-key="${e.keyCode}"]`);

//<input data-sizing="px">とかのタグのdata-sizingを取得する
const suffix = this.dataset.sizing || '';

ドキュメントのルート要素にcssスタイルをjavascritでつける
これでルートにつけたcssの変数をリアクティブに変更できる。

document.documentElement.style.setProperty(`--${this.name}` , this.value + suffix);
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?