HTML preprocessors can make writing HTML more powerful or convenient. For instance, Markdown is designed to be easier to write and read for text documents and you could write a loop in Pug.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. So you don't have access to higher-up elements like the <html>
tag. If you want to add classes there that can affect the whole document, this is the place to do it.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. If you need things in the <head>
of the document, put that code here.
The resource you are linking to is using the 'http' protocol, which may not work when the browser is using https.
CSS preprocessors help make authoring CSS easier. All of them offer things like variables and mixins to provide convenient abstractions.
It's a common practice to apply CSS to a page that styles elements such that they are consistent across all browsers. We offer two of the most popular choices: normalize.css and a reset. Or, choose Neither and nothing will be applied.
To get the best cross-browser support, it is a common practice to apply vendor prefixes to CSS properties and values that require them to work. For instance -webkit-
or -moz-
.
We offer two popular choices: Autoprefixer (which processes your CSS server-side) and -prefix-free (which applies prefixes via a script, client-side).
Any URLs added here will be added as <link>
s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself.
You can also link to another Pen here (use the .css
URL Extension) and we'll pull the CSS from that Pen and include it. If it's using a matching preprocessor, use the appropriate URL Extension and we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
JavaScript preprocessors can help make authoring JavaScript easier and more convenient.
Babel includes JSX processing.
Any URL's added here will be added as <script>
s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
Search for and use JavaScript packages from npm here. By selecting a package, an import
statement will be added to the top of the JavaScript editor for this package.
Using packages here is powered by esm.sh, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ESM usage.
All packages are different, so refer to their docs for how they work.
If you're using React / ReactDOM, make sure to turn on Babel for the JSX processing.
If active, Pens will autosave every 30 seconds after being saved once.
If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.
If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.
Visit your global Editor Settings.
<header>
<div class="container">
<h1>Animate.css + wow.js</h1>
</div>
</header>
<div class="container">
<section id="first">
<h2>Подключение плагина</h2>
<p>Давайте посмотрим, как будет вести себя анимация при прокрутке контента.</p>
<p>Ниже будут размещены блоки, которые анимируются только тогда, когда пользователь "докручивает" до них с помощью колесика мышки или вертикальной прокрутки.</p>
<p>Этот эффект достигается за счет использования плагина <a href="https://wowjs.uk/" target="blank">WOW.js</a></p>
<p>Вы можете загрузить этот плагин с помощью ссылки с CDN:</p>
<pre>
<script <span class="green">src="https://cdnjs.cloudflare.com/ajax/libs/wow/1.1.2/wow.min.js"</span> integrity="sha512-Eak/29OTpb36LLo2r47IpVzPBLXnAMPAVypbSZiZ4Qkf8p/7S/XRG5xp7OKWPPYfJT6metI+IORkR5G8F900+g==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
</pre>
<p>Затем вам нужно создать еще один блок с тегами <code><script></code> и записать в них такой код: </p>
<pre>
<script>
new WOW().init();
</script>
</pre>
<div class="row">
<div class="wow box animate__animated animate__backInDown"><img src="https://source.unsplash.com/HoC9ttceIGo/300x200" alt="Cat"></div>
<div class="wow box animate__animated animate__fadeInUp animate__delay-1s"><img src="https://source.unsplash.com/rW-I87aPY5Y/300x200" alt="Cat"></div>
<div class="wow box animate__animated animate__slideInRight animate__delay-2s"><img src="https://source.unsplash.com/w2DsS-ZAP4U/300x200" alt="Cat"></div>
</div>
<h2>Классы с анимацией для wow.js</h2>
<p>Кроме тех классов, которые вы указывали для animate.css, вам нужно будет еще добавить класс <code>wow</code>.</p>
<pre>
<div class="wow box animate__animated animate__lightSpeedInLeft">
<img src="images/cat.jpg" alt="Cat">
</div>
</pre>
<p>Задержка анимации может быть задана с помощью классов animate.css или с помощью data-атрибута из wow.js.</p>
<p>Как это сделать - выбирать вам.</p>
<p>Для изображений ниже задана задержка анимации с помощью классов <code>animate__delay-1s</code> и др.</p>
<div class="row">
<div class="wow box animate__animated animate__lightSpeedInLeft"><img src="https://source.unsplash.com/eMzblc6JmXM/300x200" alt="Cat"></div>
<div class="wow box animate__animated animate__flipInY animate__delay-1s"><img src="https://source.unsplash.com/KfPwby-UisA/300x200" alt="Cat"></div>
<div class="wow box animate__animated animate__lightSpeedInRight animate__delay-2s"><img src="https://source.unsplash.com/ZlFKIG6dApg/300x200" alt="Cat"></div>
</div>
</section>
<section id="second">
<h2>Пример с анимацией блоков с иконками</h2>
<p>С помощью animate.css и wow.js можно анимировать как изображения, так и текстовые блоки или блоки со смешанным контентом.</p>
<p>Для нижнего ряда блоков использована задержка, заданная с помощью data-атрибута <code>data-wow-delay</code>, которая предусмотрена в плагине wow.js, а не в animate.css.</p>
<div class="row">
<div class="wow animate__animated animate__rotateInDownLeft icon-service">
<div class="icon-holder"><i class="fa fa-chess-pawn"></i></div>
<h4>Service 1</h4>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Illo aliquam sunt voluptas, et quia tempora!</p>
</div>
<div class="icon-service wow animate__animated animate__rotateInDownRight">
<div class="icon-holder"><i class="fa fa-chess"></i></div>
<h4>Service 2</h4>
<p>Quas cupiditate aut fugiat fugit qui, voluptatibus exercitationem minus iusto facere, error voluptates reiciendis ut?</p>
</div>
<div class="icon-service wow animate__animated animate__rotateInUpLeft" data-wow-delay="1s">
<div class="icon-holder"><i class="fa fa-chess-rook"></i></div>
<h4>Service 3</h4>
<p>Excepturi adipisci illum molestiae. Aperiam fugit praesentium dignissimos eius quisquam minus numquam ut distinctio quis.</p>
</div>
<div class="icon-service wow animate__animated animate__rotateInUpRight" data-wow-delay="1s">
<div class="icon-holder"><i class="fa fa-chess-queen"></i></div>
<h4>Service 4</h4>
<p>Earum totam incidunt, nisi debitis ex consectetur ipsa mollitia, culpa nobis rem unde, ab a!</p>
</div>
</div>
<p class="wow animate__animated animate__fadeInLeftBig" data-wow-delay="1.5s">Обычные абзацы с текстом вы тоже можете анимировать.</p>
<p class="wow animate__animated animate__fadeInRightBig" data-wow-delay="2s">Выбирайте нужные элементы для анимации, но <strong>не переборщите с ее количеством!</strong></p>
</section>
</div>
<footer>
<div class="container">
<div class="row">
<p><a href="https://animate.style/">Animate.css</a> + <a href="https://wowjs.uk/">wow.js</a></p>
<p><a href="//html-plus.in.ua/html-page-animation-with-animate-css-and-wow-js">Статья на html-plus.in.ua</a></p>
</div>
</div>
</footer>
* {
box-sizing: border-box;
}
body {
margin: 0;
font-family: sans-serif;
}
.container {
max-width: 960px;
margin: 20px auto;
padding-left: 15px;
padding-right: 15px;
}
.row {
display: flex;
flex-wrap: wrap;
align-content: center;
justify-content: space-between;
overflow: hidden;
}
.box {
flex: 0 0 32%;
margin-bottom: 20px;
}
.box img {
display: block;
max-width: 100%;
border: 3px solid #dadada;
box-shadow: 2px 2px 8px rgba(0,0,0,.4);
}
.icon-service {
flex: 0 0 48%;
margin-bottom: 20px;
border: 3px solid #ddd;
border-radius: 10px;
padding: 8px 15px 0;
box-shadow: 2px 2px 8px rgba(0,0,0,.4);
}
.icon-holder {
display: inline-block;
margin-right: 10px;
font-size: 1.4em;
border-radius: 8px;
background-color: #f90;
padding: 10px;
min-width: 50px;
text-align: center;
box-shadow: 2px 2px 8px rgba(0,0,0,.4);
}
.icon-holder + h4 {
display: inline-block;
}
pre {
background-color: #ddd;
border: 3px double #ccc;
word-wrap: break-word;
white-space: pre-line;
padding: 10px;
}
.green {
color: #0a0;
}
code {
background-color: #ddd;
font-family: 'Courier New', monospace;
}
footer, header {
background-color: #222;
padding: 8px 0;
color: #fff;
}
footer a {
color: #fff;
}
@media (max-width: 520px){
.box {flex: 0 0 48%;}
}
new WOW().init();
Also see: Tab Triggers