
本文旨在解决将Codepen上的CSS/JS动画(特别是基于WOW.js的动画)迁移到其他IDE时遇到的依赖问题。通过详细列出所需的外部CSS和JavaScript库(如Animate.css、jQuery、WOW.js、Font Awesome和Google Fonts)的CDN链接,并提供完整的代码结构,确保动画在任何开发环境中都能正确运行,并解释了各库的作用及集成要点。
在web开发中,我们经常利用css和javascript库来增强用户界面的视觉效果和交互性。像wow.js这样的库能够实现滚动时触发的动画效果,结合animate.css等动画库,可以轻松创建动态的网页内容。然而,当我们将这些在在线开发环境(如codepen)中正常运行的代码迁移到本地ide或其他项目中时,常常会遇到“xxx is not defined”之类的错误,这通常是由于缺少必要的外部资源引用所致。本教程将详细阐述如何正确引入这些外部依赖,以确保您的动画在任何环境中都能顺利运行。
核心问题:缺失的外部依赖
在Codepen这类在线平台上,许多常用的库可能已经默认引入,或者通过简单的配置即可使用。但在本地开发环境中,您需要手动引入所有外部CSS样式表和JavaScript脚本。当您看到类似WOW is not defined的错误时,这意味着浏览器无法找到WOW这个全局对象,因为它所依赖的WOW.js库文件尚未被加载。
为了使动画和相关功能正常工作,我们需要引入以下关键库:
Google Fonts: 用于加载自定义字体,提升页面美观度。Font Awesome: 提供丰富的图标字体,常用于美化UI元素。Animate.css: 一个预设的CSS动画库,WOW.js通常与之配合使用以实现各种动画效果。jQuery: 一个流行的JavaScript库,简化了DOM操作、事件处理、动画和Ajax交互。本例中的JavaScript代码使用了jQuery的选择器和方法。WOW.js: 一个轻量级的JavaScript库,用于在用户滚动页面时显示CSS动画。它会检测带有特定CSS类(如wow和fadeInRight)的元素,并在它们进入视口时添加动画效果。
引入必要的库文件
所有外部资源通常通过CDN(内容分发网络)链接引入,这能够加快加载速度并减轻服务器负担。您需要在HTML文件的
标签内引入CSS文件,并在标签的底部(之前)引入JavaScript文件,以确保DOM元素在脚本执行前已加载。
以下是实现给定动画所需的所有CDN链接:
立即学习“前端免费学习笔记(深入)”;
完整的HTML结构与代码集成
将上述CDN链接、您的自定义CSS样式以及JavaScript代码整合到一个完整的HTML文件中,即可确保动画正常工作。
Web动画集成教程 body { font-family: Open Sans, "Helvetica Neue", "Helvetica", Helvetica, Arial, sans-serif; font-size: 13px; color: #666; position: relative; -webkit-font-smoothing: antialiased; margin: 0; } * { -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; } body, div, dl, dt, dd, ul, ol, li, h1, h2, h3, h4, h5, h6, pre, form, p, blockquote, th, td { margin: 0; padding: 0; font-size: 13px; direction: ltr; } .sectionClass { padding: 80px 0px 50px 0px; position: relative; display: block; background: rgb(249, 249, 249); } .row { width: 980px; height: 100%; max-width: 100%; margin: 0 auto; } .row:before, .row:after { content: ""; display: table; } .sectiontitle { background-position: center; text-align: center; min-height: 20px; } .sectiontitle h2 { font-size: 30px; color: #222; margin-bottom: 0px; padding-right: 10px; padding-left: 10px; } .headerLine { width: 160px; height: 2px; display: inline-block; background: #101F2E; } .fullWidth { width: 100%; display: table; float: none; padding: 0; min-height: 1px; height: 100%; position: relative; } /********************************/ /* SECTION WORK EXPERIENCE ********************************/ #work-experience .sectiontitle .headerLine { width: 280px; } #work-experience .headerline { width: 280px; } .cbp_tmtimeline { margin: 60px 30px 0 0; padding: 0; list-style: none; position: relative; } .cbp_tmtimeline:before { content: ''; position: absolute; top: 3%; bottom: 0; width: 10px; background: #324454; left: 13%; height: 100%; } .cbp_tmtimeline li:last-child:before { content: initial; } .cbp_tmtimeline > li .cbp_tmtime { display: block; width: 25%; padding-right: 100px; position: absolute; } .cbp_tmtimeline > li .cbp_tmtime span { display: block; text-align: right; } .cbp_tmtimeline > li .cbp_tmtime span:first-child { font-size: 0.9em; color: #bdd0db; } .cbp_tmtimeline > li .cbp_tmtime span:last-child { font-size: 2.9em; color: #3594cb; } .cbp_tmtimeline > li:nth-child(odd) .cbp_tmtime span:last-child { color: #6cbfee; } .cbp_tmtimeline > li .cbp_tmlabel { margin: 0 0 15px 25%; background: rgba(50, 68, 84, 1); color: #FFF; padding: 30px; font-size: 1.2em; font-weight: 300; line-height: 1.4; font-family: 'Open Sans'; position: relative; border-radius: 5px; min-height: 150px; } .cbp_tmtimeline > li:nth-child(odd) .cbp_tmlabel { background: #2B3A48; } .cbp_tmtimeline > li .cbp_tmlabel h3 { margin-top: 0px; color: white; font-size: 20px; margin-bottom: 5px; padding: 0 0 10px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.4); font-family: 'Open Sans', sans-serif; font-weight: bold; } .cbp_tmtimeline > li .cbp_tmlabel h4 { opacity: 0.7; color: rgba(255, 255, 255, 1); letter-spacing: 0px; font-family: 'Source Sans Pro', sans-serif; font-size: 18px; line-height: 1.2em; font-weight: 600; padding: 0; padding-bottom: 10px; margin: 0; text-align: left; } .cbp_tmtimeline > li .cbp_tmlabel h4 i { margin-right: 5px; vertical-align: middle; } .cbp_tmtimeline > li .cbp_tmlabel:after { right: 100%; border: solid transparent; content: " "; height: 0; width: 0; position: absolute; pointer-events: none; border-right-color: rgba(50, 68, 84, 1); border-width: 10px; top: 70px; } .cbp_tmtimeline > li:nth-child(odd) .cbp_tmlabel:after { border-right-color: #2B3A48; } .cbp_tmtimeline > li .cbp_tmicon { width: 150px; height: 150px; top: 3%; speak: none; font-style: normal; font-weight: normal; font-variant: normal; text-transform: none; font-size: 1.4em; line-height: 40px; -webkit-font-smoothing: antialiased; position: absolute; color: #151515; background: #324454; border-radius: 50%; text-align: center; left: 8%; margin: 0 0 0 -25px; } .cbp_tmtimeline li { margin-bottom: 70px; position: relative; } .sectionClassProject { position: relative; display: block; /* background: #f7f7f7; */ margin: 0 auto; padding: 80px 1.875em 3.125em; } .projectParagraph { font-size: 18px; margin: 0.5em 0 0; font-family: 'Source Sans Pro', serif; } .projectParagraphLink { font-size: 15px !important; font-weight: 500 !important; margin-top: 50px !important; margin-bottom: 0px; text-align: right; } .projectParagraphLink a { color: white; text-decoration: underline; } .cbp_tmicon img { width: 100%; } .faPra { display: inline-block; font: normal normal normal 14px/1 FontAwesome; text-rendering: auto; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; font-size: 70px; vertical-align: middle; color: white; line-height: 150px; } .label { background-color: rgba(255, 255, 255, 0.3); border-radius: 3px; color: #FFFFFF; display: inline; font-size: 12px; font-weight: bold; margin-right: 10px; padding: 5px 15px; } .date { color: #BFC3C7; display: block; font-size: 14px; font-weight: 600; position: absolute; top: 30px; right: 20px; } .date i { margin-right: 8px; vertical-align: top; font-size: 18px; line-height: 20px; } @media (max-width: 1024px) { .cbp_tmtimeline:before { display: none; } .cbp_tmtimeline > li .cbp_tmtime { width: 100%; position: relative; padding: 0 0 20px 0; } .cbp_tmtimeline > li .cbp_tmtime span { text-align: left; } .cbp_tmtimeline > li .cbp_tmlabel { margin: 30px 0 70px 0; padding: 50px 30px 30px 30px; font-weight: 400; font-size: 95%; float: left; } .cbp_tmtimeline > li .cbp_tmlabel:after { right: auto; border-right-color: transparent; border-bottom-color: rgb(50, 68, 84); top: -20px; } .cbp_tmtimeline > li:nth-child(odd) .cbp_tmlabel:after { border-right-color: transparent; border-bottom-color: rgb(43, 58, 72); left: 65px; } .cbp_tmtimeline > li:nth-child(even) .cbp_tmlabel:after { right: 65px; } .cbp_tmtimeline > li:nth-child(odd) .cbp_tmicon { position: relative; float: left; left: auto; margin: 0px 5px 0 0px; } .cbp_tmtimeline > li:nth-child(even) .cbp_tmicon { position: relative; float: right; left: auto; margin: 0px 5px 0 0px; } .cbp_tmtimeline > li .cbp_tmtime span:last-child { font-size: 1.5em; } } @media (max-width: 32em) { .cbp-ntaccordion { font-size: 70%; } } /********************************/ /* AUTHOR LINK ********************************/ footer { z-index: 100; padding-top: 50px; padding-bottom: 50px; width: 100%; bottom: 0; left: 0; } footer p { color: rgba(255, 255, 255, 0.8); font-size: 16px; opacity: 0; font-family: 'Open Sans'; width: 100%; word-wrap: break-word; line-height: 25px; -webkit-transform: translateX(-200px); transform: translateX(-200px); margin: 0; } footer .authorWindow a { text-decoration: none; } footer p strong { color: rgba(255, 255, 255, 0.9); margin-left: 5px; cursor: pointer; } .about-me-img { width: 120px; height: 120px; left: 10px; /* bottom: 30px; */ position: relative; border-radius: 100px; border: 1px solid #4A5F67; } .about-me-img img { margin-top: 8px; margin-left: 5px; } .authorWindow { width: 600px; background: #101F2E; padding: 22px 20px 22px 20px; border-radius: 5px; overflow: hidden; } .authorWindowWrapper { display: none; left: 110px; bottom: -20px; padding-left: 30px; position: absolute; } .trans { opacity: 1; -webkit-transform: translateX(0px); transform: translateX(0px); transition: all 500ms ease; } @media screen and (max-width: 768px) { .authorWindow { width: 210px; } .authorWindowWrapper { bottom: -170px; margin-bottom: 20px; } footer p { font-size: 14px; } }Work experience
Web developer
April 2014 - CurrentDavic Company, Bratislava
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Fugit obcaecati ipsa quae, iusto laudantium qui, nisi eum modi perspiciatis quasi facilis corporis iure soluta enim incidunt itaque aspernatur sequi tempora.
Web designer
Fannous Company, Prague
June 2012 - April 2014Lorem ipsum dolor sit amet, consectetur adipisicing elit. Deserunt quasi perspiciatis, aliquid sed maiores accusamus. Adipisci quidem nostrum quos quae doloremque esse a, ipsum earum, recusandae omnis dignissimos et sint.
Web designer
Techixs Company, London
November 2009 - June 2012Lorem ipsum dolor sit amet, consectetur adipisicing elit. Nulla labore atque alias ipsa, nam quod rerum repellat cumque, aliquam sequi vitae voluptatibus cum soluta incidunt tempore accusamus eius sed excepturi!Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempora natus veritatis aperiam repellendus dolor vel, expedita assumenda eos, mollitia quae ullam esse voluptas vero. Dolores culpa eaque vitae eum
以上就是在不同IDE中实现CSS/JS动画:WOW.js与其他库的集成的详细内容,更多请关注创想鸟其它相关文章!
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 chuangxiangniao@163.com 举报,一经查实,本站将立刻删除。
发布者:程序猿,转转请注明出处:https://www.chuangxiangniao.com/p/1572042.html赞 (0)打赏微信扫一扫
支付宝扫一扫
表单中的生物认证怎么集成?如何支持指纹或面部识别?上一篇 2025年12月22日 14:16:14在任何IDE中正确使用CSS/JS动画:依赖项配置指南下一篇 2025年12月22日 14:16:32
微信扫一扫
支付宝扫一扫