Эффекты анимации в html

15 Gorgeous CSS Text Animation Effects [Examples]

One important factor of website design is the font choice and the style of typography that you select. This can easily be a make or break situation. Fonts catch the eye very quickly and can engage the user or push them away, so it’s important to make the right choice.

However, fonts and typography don’t have to be static. You can introduce CSS text effects on your website to help you stand out. Things such as scrolling text, shadows, text glow, style, colour, 3D effect and many more.

On this article we’ll be focusing on CSS Text Animations. These are simple and easy to integrate into your design, with pure HTML, CSS and (in some of them) some JavaScript. You can use them on scrolling animation websites.

15 Amazing Text Animations with CSS

These CSS text animations can be used to make your webpage more interesting and give it a unique design and feel. You have to be careful though, not all of these CSS text effects will benefit every design. For example, with a minimalistic design, you may want to choose a more subtle effect (just check these Minimalist WordPress themes by yourself and you will easily find out that they could ruin their clean design)

However, there should be a design in here that fits every user’s needs and expectations to improve your design and look. Check out these 15 text animation CSS codepens that we have selected for you.

1. Scroll Trigger Text Animation

A great example of how you can take advantage of CSS text animation which is triggered by a user scrolling. This one uses a trigger both for scrolling up and down, so the animation will always work in any direction.
Scroll-triggered animations are perfect for one-page websites.

If you do not know how to create a one-page website, fullPage.js library will make it easy for you. You can even use it in WordPress builders like Elementor and Gutenberg.

And if you are looking for scroll trigger animations, this article on How to Create CSS Animations on Scroll might be very helpful for you.

2. Text Colour Animation Effect (CSS only)

This one is just pure HTML and CSS, so it will be very easy to use and does not require any JavaScript. It sends a colourful transition of different colours across the text using a gradient, giving a very modern look.

You can easily change the chosen colours to fit your own brand by altering the hex codes in the CSS.

3. Static CSS Colour Change

Great for a big title, this one changes the colour of each word without any transition. This CSS text effect can be useful if you have a minimalistic design and don’t want things to look too busy.

Читайте также:  Java cannot run program createprocess error 193

Made purely with HTML and CSS, you can easily change the colours and speed of the animation. Just try it yourself by modifying the CSS of the codepen.

4. Morphing CSS Text Effect

A more advanced animation which is made with pure HTML, CSS and JavaScript. As you can see in the text animation CSS codepen, you can make more advanced animations when you add a little JavaScript. However, this one is still relatively easy to edit and mould to your brand or style.

5. Bouncing With Reflection Text Animation (CSS only)

A bouncing CSS text effect that has a reflection, made with only HTML and CSS, making it very portable across different websites.

It uses a span HTML element to position each letter in a row and bounces each one during the text animation, so be careful where you place it.

6. Water Wave Text Animation (CSS only)

A calm water CSS text effect, it animates the effect of a calm wave within the text. Great for a range of different titles on a website, could really make it stand out.

This one only uses HTML and CSS, making it easy to work with.

7. Crossing On Scroll CSS Text Effect

If you are looking for something to trigger a text animation, an on-scroll animation like this one may be of use to you. It uses HTML, CSS and JavaScript to pull this off. The animation is light and very smooth. Scrolling the letters individually could also add more value to this CSS text effect.

8. Loading Style CSS Text Animation

Looks like a loading progress bar but in the form of a font. Change the text to anything you want and use this unique animation. You can easily change the colours of the text animation in the CSS codepen.

9. Flip Text Animation (CSS only)

Can be used as a loading animation when waiting for a response on a webpage, made with only HTML and CSS. The text flips over from left to right and is a very smooth animation.

10. Fade In Text Animation (CSS only)

A subtle text animation (CSS) that fades in when the page loads. Very smooth animation and has a subtle blur effect upon fading in. Made with pure HTML and CSS.

11. 3D Text Grow Animation

Text animation (CSS) with a 3D effect that grows up and down. A very fun and engaging animation to use.

12. Animated Blobs Text animation (CSS only)

A very subtle CSS text animation with a colourful background and engaging font type. Made with pure HTML and CSS, it is easy to change colours and font type to fit your brand and style.

13. Basic Text Animations (CSS only)

If you are looking for some basic reusable text animations (pure CSS) that can be quickly used in many places on a webpage, these ones are for you. Made with only HTML and CSS, they are easy to edit and learn from.

A catchy and engaging CSS text animation great for the main title on a webpage. It loops through different words and has a sliding animation effect to transition between each word. Made with pure HTML and CSS, so it is easy to work with and edit.

15. Typing Text Animation

A great way to showcase a range of words or sentences across a screen in one area. The typing CSS text effect looks great for many designs and uses a smooth animation. Made with HTML, CSS and JavaScript but a great one to learn from and it is easy to edit the words you need to use.

Читайте также:  Пояснение работы парсера

Conclusion

CSS Text animations are great, they help create an inviting space for the visitors and help catch the eye towards a certain location. They can suit very well in one-page websites with full screen sections, creating a very appealing design for the user. I’m thinking about product landing websites, squeeze pages, etc.

FullPage.js library is the perfect tool to create this kind of fullscreen website. It is available for WordPress builders like Elementor and Gutenberg. Add one of these CSS text animations in fullscreen mode and I’m sure the result will be promising. For example, as we explained in the 1st CSS text animation, the scroll-triggered animation fits very well in a one-page website with multiple sections.

It can be difficult to choose the right animation though, not all animations will work well on all designs, so be sure to ask yourself if the animation is too busy and maybe opt for a more subtle one. Don’t overuse CSS text effects either, it will make the page look tacky and overrun with animations.

Luke Embrey is a full-stack developer, BSc in Computer Science and based in the UK.
You can find out more about him at https://lukeembrey.com/

Join 2,000+ readers and learn something new every month!

Источник

Мини-туториал по анимации в CSS и HTML5

Обложка: Мини-туториал по анимации в CSS и HTML5

За годы работы с Front End технологиями мне приходилось работать с разными способами анимации. В этой статье я хочу подробнее разобрать, как работает анимация в CSS без использования JavaScript.

В CSS есть свойство animation, которое позволяет анимировать практически любое свойство HTML элемента. Правило анимации указывается в блоке keyframes.

Свойство animation может быть использовано для анимации других свойств CSS, таких как цвет фона, высота, длинна, положение элемента и многие другие.

Давайте рассмотрим пример, где мы меняем цвет фона у элемента.

Создадим в HTML элемент с классом «element»:

В CSS создаем правило для анимации в блоке keyframes. Назовем анимацию changeColor. Анимация будет менять цвет фона объекта с красного на синий.

@keyframes changeColor < 0% < background-color: red; >100% < background-color: blue; >>

Здесь 0% — это начало анимации, 100% — это конец анимации. Все что между движок CSS автоматически анимирует в плавное изменениe свойста, которое вы выбрали. В данном случае будет плавное изменение цвета.

Теперь добавим эту анимацию как свойство animation в CSS стилях для элемента. Наш CSS будет выглядеть таким образом:

Результат данной анимации будет выглядеть так:

Мы можем контролировать анимацию при помощи дополнительных свойств.

В данном примере после имени анимации мы указали скорость анимации (2s) и количество повторений (в данном случае бесконечное количество повторений infinite).

Существует несколько свойств анимации. Рассмотрим каждый из них:

  • animation-name: имя анимации определенным правилом keyframes
  • animation-duration: сколько времени займет один цикл анимации от 0% до 100%
  • animation-timing-function: определяет кривые ускорения, такие как ease и linear
  • animation-delay: время задержки между моментом загрузки элемента в браузере и началом анимации.
  • animation-direction: указывает направление анимации. По умолчанию анимация идет от 0% до 100%. С помощью данного свойства можно сделать так, чтобы анимация шла в обратную сторону от 100% до 0% или каждый раз меняла направление.
  • animation-iteration-count: количество повторений цикла анимации. Можно установить число или указать infinite для бесконечного повторения анимации.
  • animation-fill-mode: устанавливает значение, которое устанавливается до начала или после окончания анимации. Например, можно указать, что после завершения всех циклов анимации фон элемента будет зеленый.
  • animation-play-state: проигрывает/ставит на паузу анимацию
Читайте также:  Python face recognition deep learning

Свойства анимации указываются таким образом:

Все эти свойства можно записать и одной строкой:

Свойства анимации могут принимать значения, указанные в таблице:

Правило keyframes может иметь неограниченное количество шагов. Не обязательно только начало и конец. Можно указать значения и для середины цикла анимации:

@keyframes changeColor < 0% < background-color: red; >50% < background-color: yellow; >100% < background-color: blue; >>

HTML элементу можно одновременно присвоить несколько анимаций. Давайте добавим нашему элементу анимацию move, которая будет двигать элемент влево и вправо.

Добавим новый блок keyframes

Перечислим анимации через запятую

animation: changeColor 3s infinite, move 4s infinite alternate;

Как видите, мы присвоили одному элементу одновременно 2 анимации: движение и смену цветов.

Практические примеры

Теперь давайте рассмотрим более практические примеры применения CSS анимации, которые используются в веб страницах и веб приложениях.

Анимация спиннера загрузки

Очень часто можно увидеть во время загрузки контента вращающийся спиннер. Давайте создадим такой спиннер при помощи CSS анимации.

В этом примере мы использовали анимацию rotate, где зациклили вращение спиннера на 360 градусов.

Далее мы использовали эту анимацию в списке стилей для элемента:

animation: rotate 1.5s infinite linear

Анимированная форма авторизации

Давайте создадим что-то посложнее. Например анимированную форму авторизации.

Сделаем зацикленную анимацию для кнопки Submit. Добавим анимированный эффект для наведения курсора на кнопку. Сделаем так же анимацию для лейблов Username и Password в момент, когда поля ввода в фокусе.

 
Login
Username
Password
Submit

Обратите внимание на несколько span в кнопке Submit. Именно их мы потом и будем анимировать.

Добавим статические стили в CSS, чтобы наша форма выглядела красиво:

html < height: 100%; >body < margin:0; padding:0; font-family: sans-serif; background: linear-gradient(#141e30, #243b55); >.login-box < position: absolute; top: 50%; left: 50%; width: 400px; padding: 40px; transform: translate(-50%, -50%); background: rgba(0,0,0,.5); box-sizing: border-box; box-shadow: 0 15px 25px rgba(0,0,0,.6); border-radius: 10px; >.login-box h2 < margin: 0 0 30px; padding: 0; color: #fff; text-align: center; >.login-box .user-box < position: relative; >.login-box .user-box input < width: 100%; padding: 10px 0; font-size: 16px; color: #fff; margin-bottom: 30px; border: none; border-bottom: 1px solid #fff; outline: none; background: transparent; >.login-box .user-box label < position: absolute; top:0; left: 0; padding: 10px 0; font-size: 16px; color: #fff; pointer-events: none; transition: .5s; >.login-box .user-box input:focus ~ label, .login-box .user-box input:valid ~ label < top: -20px; left: 0; color: #03e9f4; font-size: 12px; >.login-box form a < position: relative; display: inline-block; padding: 10px 20px; color: #03e9f4; font-size: 16px; text-decoration: none; text-transform: uppercase; overflow: hidden; transition: .5s; margin-top: 40px; letter-spacing: 4px >.login-box a:hover

Теперь добавим анимации. Анимировать мы будем элементы в кнопке Submit.

Добавим 4 блока keyframes с правилами анимации:

@keyframes btn-anim1 < 0% < left: -100%; >50%,100% < left: 100%; >> @keyframes btn-anim2 < 0% < top: -100%; >50%,100% < top: 100%; >> @keyframes btn-anim3 < 0% < right: -100%; >50%,100% < right: 100%; >> @keyframes btn-anim4 < 0% < bottom: -100%; >50%,100% < bottom: 100%; >>

Как видно, мы будем использовать 4 анимации по одной для каждого . Наши элементы будут двигаться по очереди вверх, вниз, влево, вправо, создавая иллюзию беспрерывного вращения вокруг кнопки.

Добавим теперь эту анимацию каждому элементу:

.login-box a span:nth-child(1) < animation: btn-anim1 1s linear infinite; >.login-box a span:nth-child(2) < animation: btn-anim2 1s linear infinite; animation-delay: .25s >.login-box a span:nth-child(3) < animation: btn-anim3 1s linear infinite; animation-delay: .5s >.login-box a span:nth-child(4)

Как видите, мы добились стильной анимации, используя только HTML и CSS.

Заключение

В данной статье мы рассмотрели, как использовать анимацию CSS и HTML без использования JavaScript. Инструментарий предоставляемый CSS очень гибкий: можно использовать его для создания большого количество разных анимаций, где лимитом будет только ваше воображение и здравый смысл. Вот здесь можно посмотреть различные креативные CSS анимации для вдохновения.

Источник

Оцените статью