• Что бы вступить в ряды "Принятый кодер" Вам нужно:
    Написать 10 полезных сообщений или тем и Получить 10 симпатий.
    Для того кто не хочет терять время,может пожертвовать средства для поддержки сервеса, и вступить в ряды VIP на месяц, дополнительная информация в лс.

  • Пользаватели которые будут спамить, уходят в бан без предупреждения. Спам сообщения определяется администрацией и модератором.

  • Гость, Что бы Вы хотели увидеть на нашем Форуме? Изложить свои идеи и пожелания по улучшению форума Вы можете поделиться с нами здесь. ----> Перейдите сюда
  • Все пользователи не прошедшие проверку электронной почты будут заблокированы. Все вопросы с разблокировкой обращайтесь по адресу электронной почте : info@guardianelinks.com . Не пришло сообщение о проверке или о сбросе также сообщите нам.

How to Make a Simple Bounce Animation with Just HTML and CSS

Lomanu4 Оффлайн

Lomanu4

Команда форума
Администратор
Регистрация
1 Мар 2015
Сообщения
1,481
Баллы
155
Ever wanted to add a little bounce to your UI without JavaScript? Let’s walk through how to do it with just HTML and CSS...no fuss, it's a walk in the park.

In this tutorial, you'll learn how to create a smooth bounce animation for any element (text, button, image, etc.) using only HTML and CSS.

Let's jump right into it, shall we?

Steps

1. Start with a basic HTML structure


Let’s say we want to bounce a circle:
<div class="bounce"></div>

2. Style it with CSS


Give it some shape and bounce:
.bounce {
width: 100px;
height: 100px;
background: #00bfff;
border-radius: 50%;
position: relative;
animation: bounce 2s infinite;
}

3. Add the bounce animation


Now for the juicy part:

@keyframes bounce {
0%, 100% {
top: 0;
animation-timing-function: ease-in;
}

50% {
top: 100px;
animation-timing-function: ease-out;
}
}

You may be wondering how I arrived at the blocks of code in the @keyframes....worry no more, here's the breakdown:

  • 0% and 100%: Element is at the top.
  • 50%: Drops down (you can adjust the 150px for a higher or lower bounce).
  • ease-in and ease-out: Makes it feel more natural — fast drop, slow rise.

Here’s a quick demo on

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

(you can plug this into your own HTML file too).

You can also view it in action in my

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

.

Bonus Tip


Now what's a tutorial without a bonus tip? I got you, worry less.
If you want the bounce to feel more dramatic, try adding scale or tweaking the duration, thus:

@keyframes bounce {
0%, 100% {
transform: scale(1);
}

50% {
transform: scale(1.3);
}
}

I'm curious to know if you've ever used CSS animations like this before. So if you've got cooler tricks, drop them in the comments. Or let me know what else you'd like to see next!

Thank you for reading! Follow me for more bite-sized tutorials like this.


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

 
Вверх Снизу