/* Анимация для кота, который появляется снизу */
.final-cat {
position: absolute;
bottom: -200px; /* Начальная позиция за пределами экрана */
width: 150px;
height: 150px;
background-image: url('https://stickermaker.s3.eu-west-1.amazonaws.com/storage/uploads/sticker-pack/3-1618604576/sticker_4.png?ae9fdb16c61783155c0e1ed3f5722212&d=200x200');
background-size: cover;
animation: slideUp 2s ease forwards; /* Анимация выезда */
}
@keyframes slideUp {
0% { bottom: -200px; }
100% { bottom: 100px; } /* Конечная позиция (выше, чем было) */
}
</style>
Да
Нет
<script>
const questions = [
"Ты моя принцесса? ❤️",
"А ты меня любишь?",
"А ты со мной будешь?",
"И будем мы вместе?"
];
const yesButton = document.getElementById('yesButton');
const noButton = document.getElementById('noButton');
const questionElement = document.getElementById('question');
let currentQuestion = 0;
// Функция для обновления вопроса
const updateQuestion = () => {
questionElement.textContent = questions[currentQuestion];
};
// Обработчик для кнопки "Да"
yesButton.addEventListener('click', () => {
if (currentQuestion < questions.length - 1) {
currentQuestion++;
updateQuestion();
} else {
questionElement.textContent = "С тобой навсегда ❤️";
yesButton.style.display = 'none';
noButton.style.display = 'none';
// Создаем кота, который появляется снизу
const finalCat = document.createElement('div');
finalCat.classList.add('final-cat');
document.body.appendChild(finalCat);
}
});
// Обработчик для кнопки "Нет" (убегает)
noButton.addEventListener('mouseover', () => {
const x = Math.random() * (window.innerWidth - noButton.offsetWidth);
const y = Math.random() * (window.innerHeight - noButton.offsetHeight);
noButton.style.position = 'absolute'; // Переключаем на absolute для перемещения
noButton.style.left = `${x}px`;
noButton.style.top = `${y}px`;
});
// Инициализация первого вопроса
updateQuestion();
// Массив с URL стикеров котиков
const catStickers = [
'https://yt3.googleusercontent.com/ytc/AIf8zZTkPm56NKejsc_jHhr0g6desEcNq30Z2NtRZWitEw=s900-c-k-c0x00ffffff-no-rj',
'https://data.chpic.su/stickers/p/PinkPussyCat/PinkPussyCat_002.webp',
// Добавьте больше URL стикеров, если нужно
];
// Динамическое создание котиков
function createCat() {
const cat = document.createElement('div');
cat.classList.add('falling-cats');
cat.style.left = `${Math.random() * window.innerWidth}px`;
cat.style.animationDuration = `${Math.random() * 4 + 3}s`; // Замедляем падение
cat.style.backgroundImage = `url('${catStickers[Math.floor(Math.random() * catStickers.length)]}')`;
document.body.appendChild(cat);
// Удаляем котика после завершения анимации
setTimeout(() => {
cat.remove();
}, 8000); // Увеличено время удаления
}
// Создаем котиков реже (каждые 500 мс)
setInterval(createCat, 500);
</script>