логика для замены картинки на гиф при наведении

This commit is contained in:
xomimishka committed 2025-07-11 11:35:04 +03:00
1 parent 0569b78d94
commit 1622a1bc50
3 files changed
+42 -4

No files matched your search

+25 -1
View File
@@ -2,7 +2,27 @@
margin-bottom: 60px;
img {
pointer-events: none;
//pointer-events: none;
}
.image-wrapper {
display: inline-block;
position: relative;
img {
display: block;
// Все остальные стили из предыдущего примера
}
// Дополнительная защита для Firefox
&::after {
content: "";
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
}
label {
@@ -50,9 +70,11 @@
@media (max-width: 768px) {
margin-bottom: 24px;
.block-content {
margin-top: 24px;
}
.numbers-grid {
grid-template-columns: repeat(2, 1fr); // 2 колонки на мобильных (2x3)
}
@@ -60,9 +82,11 @@
@media (max-width: 500px) {
margin-bottom: 24px;
.block-content {
margin-top: 24px;
}
label {
font-size: 14px;
margin-top: 5px;
+15 -2
View File
@@ -1,9 +1,11 @@
import "./Numbers.styles.scss";
import { Illustration } from '@/shared/assets/images/numbers';
import { Illustration, Illustration2 } from '@/shared/assets/images/numbers';
import { useState } from 'react';
const Numbers = () => {
const currentYear = new Date().getFullYear();
const yearsSince2015 = currentYear - 2015;
const [isHovered, setIsHovered] = useState(false);
return (
<div className="block" id="numbers">
@@ -35,7 +37,18 @@ const Numbers = () => {
<label>обученных студентов</label>
</div>
</div>
<img className="visible" src={Illustration} alt="Illustration" />
<div
className="image-wrapper"
onMouseEnter={() => setIsHovered(true)}
onMouseLeave={() => setIsHovered(false)}
>
<img
className="visible"
src={isHovered ? Illustration : Illustration}
alt="СКБ КИТ"
draggable="false"
/>
</div>
</div>
</div>
);