花里胡哨的console.log (尾)

接着上期文章讲到在浏览器里 控制台的JS css html是有些兼容限制的 考虑到这些能力和限制,我们可以做哪些事情呢?这里有一些额外的想法可以激发您的灵感!

花里胡哨的console.log (尾)关注下方公众号,获取更多热点资讯花里胡哨的console.log (尾)


渐变效果

花里胡哨的console.log (尾)
console.info(
  '%c ',
  `padding-left:750px;padding-top:200px;background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 750 200'%3E%3Cstyle%3E text %7B font-family: sans-serif; font-weight: 100; fill: %23d8eaff; %7D %23stop1 %7B animation: recolor 40s linear infinite alternate %7D %23stop2 %7B animation: recolor 40s -32s linear infinite alternate %7D @keyframes recolor %7B 0%25 %7B stop-color: %23388bee; %7D 20%25 %7B stop-color: %2324c6dc; %7D 40%25 %7B stop-color: %23af74fd; %7D 60%25 %7B stop-color: %23c020d9; %7D 80%25 %7B stop-color: %23514a9d; %7D 100%25 %7B stop-color: %23053ece; %7D %7D %3C/style%3E%3Cdefs%3E%3ClinearGradient id='grad'%3E%3Cstop id='stop1' offset='0%25' stop-color='%23388bee'%3E%3C/stop%3E%3Cstop id='stop2' offset='100%25' stop-color='%23514a9d'%3E%3C/stop%3E%3C/linearGradient%3E%3C/defs%3E%3Crect width='750' height='500' fill='url(%23grad)'%3E%3C/rect%3E%3Ctext text-anchor='end' font-size='50' x='725' y='125'%3E thanks for %3C/text%3E%3Ctext text-anchor='end' font-size='50' x='725' y='175'%3E stopping by %3C/text%3E%3C/svg%3E")`
);

线性动画效果

花里胡哨的console.log (尾)
代码详见GitHub地址 https://github.com/AyongNice/consoleDelight

粒子效果

❄️飘落的场景花里胡哨的console.log (尾)

代码详见GitHub地址 https://github.com/AyongNice/consoleDelight

奔跑的动画关键帧

花里胡哨的console.log (尾)
代码详见GitHub地址 https://github.com/AyongNice/consoleDelight

下面的示例展示了您可以使用 JavaScript 切换 SVG 的文本(使用.textContent,而不是.innerText因为它是 SVG 元素)。话虽如此,由于使用setInterval和requestAnimationFrame6的限制,您无法执行诸如打乱文本效果之类的操作。

代码详见GitHub地址 https://github.com/AyongNice/consoleDelight

文字关键帧

代码详见GitHub地址 https://github.com/AyongNice/consoleDelight

随机出现关键帧图片

代码详见GitHub地址 https://github.com/AyongNice/consoleDelight

输出可跳转链接

代码都在这个链接里哟花里胡哨的console.log (尾)

响应式尺寸调整

不幸的是,我找不到一种方法让消息跨越控制台宽度的 100%。我相信这是因为我们无法更改控制台中元素的显示,因此像 width: 100% 这样的东西在这里不起作用。该元素必须具有以像素(或其他非相对单位)为单位的明确宽度和高度,否则其大小将基于文本。

我确实注意到它console.table([‘foo’])跨越了整个宽度,但据我所知,我们无法在控制台表上使用 CSS 样式。

将来,我希望浏览器能够在控制台中添加响应式宽度元素。

浏览器支持

以下是 Adobeconsole.info命令在各种浏览器中的外观:铬和边缘 这是您在文章前面看到的内容,再次在这里重新发布

花里胡哨的console.log (尾)

火狐浏览器

花里胡哨的console.log (尾)

我们需要做一下更改

代码详见GitHub地址 https://github.com/AyongNice/consoleDelight

css-doodle

花里胡哨的console.log (尾)
代码详见GitHub地址 https://github.com/AyongNice/consoleDelight

表情符号在控制台中运行良好。有时,这可能就是您所需要的!花里胡哨的console.log (尾)

佛祖开光 ,永无BUG

花里胡哨的console.log (尾)
console.log(
   `%c
         ......................我佛慈悲......................
                       _oo0oo_
                      o8888888o
                      88\" . \"88
                      (| -_- |)
                      0\\  =  /0
                    ___/‘---’\\___
                  .' \\|       |/ '.
                 / \\\\|||  :  |||// \\
                / _||||| -卍-|||||_ \\
               |   | \\\\\\  -  /// |   |
               | \\_|  ''\\---/''  |_/ |
               \\  .-\\__  '-'  ___/-. /
             ___'. .'  /--.--\\  '. .'___
          .\"\" ‘<  ‘.___\\_<|>_/___.’ >’ \"\".
         | | :  ‘- \\‘.;‘\\ _ /’;.’/ - ’ : | |
         \\  \\ ‘_.   \\_ __\\ /__ _/   .-’ /  /
     =====‘-.____‘.___ \\_____/___.-’___.-’=====
                       ‘=---=’
                       
....................佛祖开光 ,永无BUG..................
`,
   `font-family: monospace`
);

我希望这篇文章能够激励开发人员和公司实现令人愉快的控制台惊喜。我认为它应该成为网站的正常补充!

关注阿勇学前端 每天分享有趣的知识




原文始发于微信公众号(阿勇学前端):花里胡哨的console.log (尾)

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

文章由极客之音整理,本文链接:https://www.bmabk.com/index.php/post/248549.html

(0)
小半的头像小半

相关推荐

发表回复

登录后才能评论
极客之音——专业性很强的中文编程技术网站,欢迎收藏到浏览器,订阅我们!