28
30

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 5 years have passed since last update.

console.log でログに色付けたり枠付けたり

Last updated at Posted at 2013-04-13

Log – Console.log with Style を見て初めて知ったのでメモ。

こんなことができる:

スクリーンショット

%c 以降にスタイルが適応される。スタイルの属性は CSS と同じ。

console.log('%cfoo', 'color:red');
// => 赤い foo

console.log('%cfoo%cbar', 'color:red', '');
// => 赤い foo 普通の bar
// 空文字でリセット

console.log('%cfoo', 'font-size:20px; padding: 10px; background: #999; border-radius: 5px;');
// => 灰色背景の foo

よくよく調べると、%o なんてものもあるんですね。

28
30
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
28
30

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?