0

0

在不同IDE中实现CSS/JS动画:WOW.js与其他库的集成

花韻仙語

花韻仙語

发布时间:2025-08-15 20:46:00

|

671人浏览过

|

来源于php中文网

原创

在不同IDE中实现CSS/JS动画:WOW.js与其他库的集成

本文旨在解决将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库文件尚未被加载。

为了使动画和相关功能正常工作,我们需要引入以下关键库:

  1. Google Fonts: 用于加载自定义字体,提升页面美观度。
  2. Font Awesome: 提供丰富的图标字体,常用于美化UI元素。
  3. Animate.css: 一个预设的CSS动画库,WOW.js通常与之配合使用以实现各种动画效果。
  4. jQuery: 一个流行的JavaScript库,简化了DOM操作、事件处理、动画和Ajax交互。本例中的JavaScript代码使用了jQuery的选择器和方法。
  5. WOW.js: 一个轻量级的JavaScript库,用于在用户滚动页面时显示CSS动画。它会检测带有特定CSS类(如wow和fadeInRight)的元素,并在它们进入视口时添加动画效果。

引入必要的库文件

所有外部资源通常通过CDN(内容分发网络)链接引入,这能够加快加载速度并减轻服务器负担。您需要在HTML文件的<head>标签内引入CSS文件,并在<body>标签的底部(</body>之前)引入JavaScript文件,以确保DOM元素在脚本执行前已加载。

以下是实现给定动画所需的所有CDN链接:

ImgGood
ImgGood

免费在线AI照片编辑器

下载

立即学习前端免费学习笔记(深入)”;

<!-- Google Fonts - Source Sans Pro -->
<link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,700,900&amp" rel="stylesheet"/>
<!-- Google Fonts - Open Sans -->
<link href="https://fonts.googleapis.com/css?family=Open+Sans:400,700&subset=latin,latin-ext" rel="stylesheet"/>
<!-- Font Awesome for icons -->
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.4.0/css/font-awesome.min.css" rel="stylesheet"/>
<!-- Animate.css for predefined animations -->
<link href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.2.6/animate.min.css" rel="stylesheet"/>

<!-- jQuery library (must be loaded before WOW.js and your custom scripts) -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<!-- WOW.js library -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/wow/1.1.2/wow.min.js"></script>

完整的HTML结构与代码集成

将上述CDN链接、您的自定义CSS样式以及JavaScript代码整合到一个完整的HTML文件中,即可确保动画正常工作。

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Web动画集成教程</title>

    <!-- 外部CSS库引用 -->
    <link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,700,900&amp" rel="stylesheet"/>
    <link href="https://fonts.googleapis.com/css?family=Open+Sans:400,700&subset=latin,latin-ext" rel="stylesheet"/>
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.4.0/css/font-awesome.min.css" rel="stylesheet"/>
    <link href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.2.6/animate.min.css" rel="stylesheet"/>

    <!-- 自定义CSS样式 -->
    <style>
        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;
            }
        }
    </style>
</head>
<body>

    <!-- 页面内容 -->
    <div id="workexperience" class="sectionClass">
        <div class="row ">
            <div class="sectiontitle">
                <h2>Work experience</h2>
                <span class="headerLine"></span>
            </div>
            <div class="fullWidth eight columns">
                <ul class="cbp_tmtimeline">
                    <li>
                        <div class="cbp_tmicon cbp_tmicon-phone">
                            <i class="faPra fa-briefcase"></i>
                        </div>
                        <div class="cbp_tmlabel wow fadeInRight animated">
                            <h3>Web developer</h3>
                            <div class="date">
                                <i class="fa fa-calendar"></i>April 2014 - Current
                            </div>
                            <h4><i class="fa fa-flag"></i>Davic Company, Bratislava</h4>
                            <p class="projectParagraph">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.</p>
                        </div>
                    </li>
                    <li>
                        <div class="cbp_tmicon cbp_tmicon-screen">
                            <i class="faPra fa-briefcase"></i>
                        </div>
                        <div class="cbp_tmlabel wow fadeInRight animated">
                            <h3>Web designer</h3>
                            <h4><i class="fa fa-flag"></i>Fannous Company, Prague</h4>
                            <div class="date"><i class="fa fa-calendar"></i>June 2012 - April 2014</div>
                            <p class="projectParagraph">Lorem 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.</p>
                        </div>
                    </li>
                    <li>
                        <div class="cbp_tmicon cbp_tmicon-mail">
                            <i class="faPra fa-briefcase"></i>
                        </div>
                        <div class="cbp_tmlabel wow fadeInRight animated">
                            <h3>Web designer</h3>
                            <h4><i class="fa fa-flag"></i>Techixs Company, London</h4>
                            <div class="date"><i class="fa fa-calendar"></i>November 2009 - June 2012</div>
                            <p class="projectParagraph">Lorem 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

热门AI工具

更多
DeepSeek
DeepSeek

幻方量化公司旗下的开源大模型平台

豆包大模型
豆包大模型

字节跳动自主研发的一系列大型语言模型

WorkBuddy
WorkBuddy

腾讯云推出的AI原生桌面智能体工作台

腾讯元宝
腾讯元宝

腾讯混元平台推出的AI助手

文心一言
文心一言

文心一言是百度开发的AI聊天机器人,通过对话可以生成各种形式的内容。

讯飞写作
讯飞写作

基于讯飞星火大模型的AI写作工具,可以快速生成新闻稿件、品宣文案、工作总结、心得体会等各种文文稿

即梦AI
即梦AI

一站式AI创作平台,免费AI图片和视频生成。

ChatGPT
ChatGPT

最最强大的AI聊天机器人程序,ChatGPT不单是聊天机器人,还能进行撰写邮件、视频脚本、文案、翻译、代码等任务。

相关专题

更多
jquery插件有哪些
jquery插件有哪些

jquery插件有jQuery UI、jQuery Validate、jQuery DataTables、jQuery Slick、jQuery LazyLoad、jQuery Countdown、jQuery Lightbox、jQuery FullCalendar、jQuery Chosen和jQuery EasyUI等。本专题为大家提供jquery插件相关的文章、下载、课程内容,供大家免费下载体验。

156

2023.09.12

jquery怎么操作json
jquery怎么操作json

操作的方法有:1、“$.parseJSON(jsonString)”2、“$.getJSON(url, data, success)”;3、“$.each(obj, callback)”;4、“$.ajax()”。更多jquery怎么操作json的详细内容,可以访问本专题下面的文章。

337

2023.10.13

jquery删除元素的方法
jquery删除元素的方法

jquery可以通过.remove() 方法、 .detach() 方法、.empty() 方法、.unwrap() 方法、.replaceWith() 方法、.html('') 方法和.hide() 方法来删除元素。更多关于jquery相关的问题,详情请看本专题下面的文章。php中文网欢迎大家前来学习。

406

2023.11.10

jQuery hover()方法的使用
jQuery hover()方法的使用

hover()是jQuery中一个常用的方法,它用于绑定两个事件处理函数,这两个函数将在鼠标指针进入和离开匹配的元素时执行。想了解更多hover()的相关内容,可以阅读本专题下面的文章。

515

2023.12.04

jquery实现分页方法
jquery实现分页方法

在jQuery中实现分页可以使用插件或者自定义实现。想了解更多jquery分页的相关内容,可以阅读本专题下面的文章。

312

2023.12.06

jquery中隐藏元素是什么
jquery中隐藏元素是什么

jquery中隐藏元素是非常重要的一个概念,在使用jquery隐藏元素之前,需要先了解css样式中关于元素隐藏的属性,比如display、visibility、opacity等属性。本专题为大家提供相关的文章、下载、课程内容,供大家免费下载体验。

129

2024.02.23

jquery中什么是高亮显示
jquery中什么是高亮显示

jquery中高亮显示是指对页面搜索关键词时进行高亮显示,其实现办法:1、先获取要高亮显示的行,获取搜索的内容,再遍历整行内容,最后添加高亮颜色;2、使用“jquery highlight”高亮插件。本专题为大家提供相关的文章、下载、课程内容,供大家免费下载体验。

183

2024.02.23

jQuery 正则表达式相关教程
jQuery 正则表达式相关教程

本专题整合了jQuery正则表达式相关教程大全,阅读专题下面的文章了解更多详细内容。

51

2026.01.13

TypeScript类型系统进阶与大型前端项目实践
TypeScript类型系统进阶与大型前端项目实践

本专题围绕 TypeScript 在大型前端项目中的应用展开,深入讲解类型系统设计与工程化开发方法。内容包括泛型与高级类型、类型推断机制、声明文件编写、模块化结构设计以及代码规范管理。通过真实项目案例分析,帮助开发者构建类型安全、结构清晰、易维护的前端工程体系,提高团队协作效率与代码质量。

49

2026.03.13

热门下载

更多
网站特效
/
网站源码
/
网站素材
/
前端模板

精品课程

更多
相关推荐
/
热门推荐
/
最新课程
Sass 教程
Sass 教程

共14课时 | 0.9万人学习

Bootstrap 5教程
Bootstrap 5教程

共46课时 | 3.6万人学习

CSS教程
CSS教程

共754课时 | 43.4万人学习

关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送

Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号