第三方趣味console,比我的强太多了,使用这个吧:

  1. https://github.com/yy0608/console

我的console效果图:

  1. ;(function (global, factory) {
  2. "use strict";
  3.  
  4. if ( typeof module === "object" && typeof module.exports === "object" ) {
  5.  
  6. // For CommonJS and CommonJS-like environments where a proper `window`
  7. // is present, execute the factory and get jQuery.
  8. // For environments that do not have a `window` with a `document`
  9. // (such as Node.js), expose a factory as module.exports.
  10. // This accentuates the need for the creation of a real `window`.
  11. // e.g. var jQuery = require("jquery")(window);
  12. // See ticket #14549 for more info.
  13. module.exports = global.document ? factory(global, true) : function( w ) {
  14. if ( !w.document ) {
  15. throw new Error( "jQuery requires a window with a document" );
  16. }
  17. return factory( w );
  18. };
  19. } else {
  20. factory( global );
  21. }
  22.  
  23. })( typeof window !== "undefined" ? window : this, function( window, noGlobal ) {
  24.  
  25. var
  26. log,
  27. sendText,
  28. shadowText,
  29. colorFulText,
  30. rainBowText;
  31.  
  32. sendText = function (_arguments, _css) {
  33. // 获取第一个文本参数并且绑定color
  34. var str = _arguments[0];
  35. // 判断第一个参数是否为字符串类型
  36. if (Object.prototype.toString.call(str) === "[object String]" || Object.prototype.toString.call(str) === "[object Number]") {
  37. str = "%c" + str;
  38. // 将类数组转化为数组
  39. var arr = [].slice.call(_arguments);
  40. // 替换第一个参数为拼接【%c】的字符串
  41. arr.splice(0,1,str);
  42. // 向数组索引为【1】的位置插入css字符串
  43. arr.splice(1,0,_css);
  44. // 调用console.log
  45. console.log.apply(console,arr);
  46. } else {
  47. console.error("第一个参数必须为String类型或Number类型");
  48. return false;
  49. }
  50. return true;
  51. }
  52.  
  53. // 3D文本
  54. shadowText = function () {
  55. var css = "text-shadow: 0 1px 0 #ccc,0 2px 0 #c9c9c9,0 3px 0 #bbb,0 4px 0 #b9b9b9,0 5px 0 #aaa,0 6px 1px rgba(0,0,0,.1),0 0 5px rgba(0,0,0,.1),0 1px 3px rgba(0,0,0,.3),0 3px 5px rgba(0,0,0,.2),0 5px 10px rgba(0,0,0,.25),0 10px 10px rgba(0,0,0,.2),0 20px 20px rgba(0,0,0,.15);font-size:5em";
  56. sendText(arguments,css);
  57. }
  58.  
  59. // 富背景文本
  60. colorFulText = function () {
  61. var css = "background: rgba(252,234,187,1);background: -moz-linear-gradient(left, rgba(252,234,187,1) 0%, rgba(175,250,77,1) 12%, rgba(0,247,49,1) 28%, rgba(0,210,247,1) 39%,rgba(0,189,247,1) 51%, rgba(133,108,217,1) 64%, rgba(177,0,247,1) 78%, rgba(247,0,189,1) 87%, rgba(245,22,52,1) 100%);background: -webkit-gradient(left top, right top, color-stop(0%, rgba(252,234,187,1)), color-stop(12%, rgba(175,250,77,1)), color-stop(28%, rgba(0,247,49,1)), color-stop(39%, rgba(0,210,247,1)), color-stop(51%, rgba(0,189,247,1)), color-stop(64%, rgba(133,108,217,1)), color-stop(78%, rgba(177,0,247,1)), color-stop(87%, rgba(247,0,189,1)), color-stop(100%, rgba(245,22,52,1)));background: -webkit-linear-gradient(left, rgba(252,234,187,1) 0%, rgba(175,250,77,1) 12%, rgba(0,247,49,1) 28%, rgba(0,210,247,1) 39%, rgba(0,189,247,1) 51%, rgba(133,108,217,1) 64%, rgba(177,0,247,1) 78%, rgba(247,0,189,1) 87%, rgba(245,22,52,1) 100%);background: -o-linear-gradient(left, rgba(252,234,187,1) 0%, rgba(175,250,77,1) 12%, rgba(0,247,49,1) 28%, rgba(0,210,247,1) 39%, rgba(0,189,247,1) 51%, rgba(133,108,217,1) 64%, rgba(177,0,247,1) 78%, rgba(247,0,189,1) 87%, rgba(245,22,52,1) 100%);background: -ms-linear-gradient(left, rgba(252,234,187,1) 0%, rgba(175,250,77,1) 12%, rgba(0,247,49,1) 28%, rgba(0,210,247,1) 39%, rgba(0,189,247,1) 51%, rgba(133,108,217,1) 64%, rgba(177,0,247,1) 78%, rgba(247,0,189,1) 87%, rgba(245,22,52,1) 100%);background: linear-gradient(to right, rgba(252,234,187,1) 0%, rgba(175,250,77,1) 12%, rgba(0,247,49,1) 28%, rgba(0,210,247,1) 39%, rgba(0,189,247,1) 51%, rgba(133,108,217,1) 64%, rgba(177,0,247,1) 78%, rgba(247,0,189,1) 87%, rgba(245,22,52,1) 100%);filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#fceabb', endColorstr='#f51634', GradientType=1 );font-size:5em";
  62. sendText(arguments,css);
  63. }
  64.  
  65. // 彩虹文本
  66. rainBowText = function () {
  67. var css = "background-image:-webkit-gradient( linear, left top, right top, color-stop(0, #f22), color-stop(0.15, #f2f), color-stop(0.3, #22f), color-stop(0.45, #2ff), color-stop(0.6, #2f2),color-stop(0.75, #2f2), color-stop(0.9, #ff2), color-stop(1, #f22) );color:transparent;-webkit-background-clip: text;font-size:5em;";
  68. sendText(arguments,css);
  69. }

  70. // 函数对象
  71. log = {
  72. shadowText: shadowText,
  73. colorFulText: colorFulText,
  74. rainBowText: rainBowText
  75. }

  76. // 加入全局上下文
  77. if (!noGlobal) {
  78. window.log = window.$log = log;
  79. }
  80.  
  81. return log;
  82. })

使用方法:

- 参数的数量不限定

- 但第1个参数必须为String类型或者Number类型,作为被css渲染的文本。

  1. $log.shadowText("Hello World",{name:"贝尔塔猫"},1,2,3,4,5,6,8) # 输出
  2. $log.colorFulText(123,{name:"贝尔塔猫"},1,2,3,4,5,6,7,8,9,0)    # 输出
  3. $log.rainBowText([],{name:"贝尔塔猫"})  # 报错

趣味 console.log的更多相关文章

  1. const let,console.log('a',a)跟console.log('a'+a)的区别

    const 创建一个只读的常量 let块级作用域 const let重复赋值都会报错 console.log('a',a) a console.log('a'+a) a2 逗号的值会有空格:用加号的值 ...

  2. console.log("A"-"B"+"3")=?

    (点击上方的订阅号,可快速关注,关注有惊喜哦^_^) 前不久看到一道JS基础题目,做了一下竟然错了一半...在此分享一下: 先把题目放上来,大家可以自己测试一下再看答案哦^_^ ①console.lo ...

  3. javascript的console.log用法

    f1.html代码 <iframe id="frame2" name="frame1" src="ww.html"></i ...

  4. alert()与console.log()的区别

    [1]alert() [1.1]有阻塞作用,不点击确定,后续代码无法继续执行 [1.2]alert()只能输出string,如果alert输出的是对象会自动调用toString()方法 e.g. al ...

  5. console.log((function f(n){return ((n > 1) ? n * f(n-1) : n)})(5))调用解析

    console.log((function f(n){) ? n * f(n-) : n)})()); 5被传入到函数,函数内部三元计算,5 > 1成立,运算结果是5*f(4),二次运算,5*4 ...

  6. JS高级群的日常!写一个从10到0的倒计时,用console.log打印,不可以用 setInterval!本来说好的研究avalonJS最后演变成了看着大神在那边互相比拼实力。。

      JS高级群的日常!写一个从10到0的倒计时,用console.log打印,不可以用 setInterval!本来说好的研究avalonJS最后演变成了看着大神在那边互相比拼实力..   小森执行一 ...

  7. console.dir() 与 console.log() 区别

    Difference console.log prints the element in an HTML-like tree console.dir prints the element in a J ...

  8. 简述alert和console.log的区别

    生活中还是得有发现美好和差别的眼睛~~ 学习前端那么久既然还不知道alert和console.log的差别~~~~ 蓝瘦,香菇~~~ 本菜鸟一直以为alert和console.log其实是一样的用法, ...

  9. console.log()与alert()的区别

    1.alert() a.有阻塞作用,不点击确定,后续代码无法继续执行 b.alert只能输出string,如果alert输出的是对象,会自动调用toString()方法 eg:alert([1,2,3 ...

随机推荐

  1. Express处理GET/POST请求(POST请求包含文件)

    Express处理GET/POST请求(POST请求包含文件) GET 使用简洁的pug模板引擎,写一个表单,提交方法是GET 前端页面代码 enctype,默认是application/x-www- ...

  2. python url拼接

    import datetime,requests import json,time,urllib import hashlib self.url_domain = “www.baidu,com/” u ...

  3. 微信小程序开发教程(八)视图层——.wxml详解

    框架的视图层由WXMKL(WeiXin Markup language)与WXSS(WeiXin Style Sheet)编写,由组件进行展示. 对于微信小程序而言,视图层就是所有.wxml文件与.w ...

  4. AGC 025 B - RGB Coloring

    B - RGB Coloring Time limit : 2sec / Memory limit : 1024MB Score : 700 points Problem Statement Taka ...

  5. Codeforces 920 F SUM and REPLACE

    Dicription Let D(x) be the number of positive divisors of a positive integer x. For example, D(2) =  ...

  6. 【欧拉函数】BZOJ2190-[SDOI2012]longge的数学问题

    [题目大意] 求出∑gcd(i, N)(1<=i <=N). [思路] 对于x=ak,y=bk,若gcd(a,b)=1则必有gcd(x,y)=1.枚举N的所有因数,∑gcd(i, N)=∑ ...

  7. tomcat访问(access)日志配置、记录Post请求参数(转)

    一.配置与说明 tomcat访问日志格式配置,在config/server.xml里Host标签下加上 <Valve className="org.apache.catalina.va ...

  8. [Java基础] Java多线程-工具篇-BlockingQueue

    转载自: http://www.cnblogs.com/jackyuj/archive/2010/11/24/1886553.html 前言: 在新增的Concurrent包中,BlockingQue ...

  9. osgMulitiplerendertargets sample 中fbo使用【HTC VIVE开发中应用】

    osgmultiplerendertargets.cpp ...................................... // now create the camera to do t ...

  10. Unity3D之高级渲染-Shader Forge增强版

    笔者介绍:姜雪伟,IT公司技术合伙人,IT高级讲师,CSDN社区专家.特邀编辑.畅销书作者,国家专利发明人;已出版书籍:<手把手教你架构3D游戏引擎>电子工业出版社和<Unity3D ...