как увеличивать элемент grid
не получается выделять элемент при помощи grid. Суть такая: как только я делаю элемент активным - все соседние должны ужиматься, а активный увеличиваться. И так должно со всеми через click происходить. Через display: flex получилось сделать, но хочется освоить и grid. Вот так расположил элементы через Grid
.container {
padding: 0 1rem;
display: grid;
grid-template-columns: auto auto 800px auto auto;
grid-auto-flow: column dense;
gap: 1rem;
grid-auto-rows: 100vh;
align-items: center;
}
позиция 800px должна перемещаться по нажатию кнопкой. Не знаю, что добавить в стили
.slide.active {
}
вот html
<body>
<div class="container">
<div
class="slide active"
style="
background-image: url('https://images.unsplash.com/photo-1583121274602-3e2820c69888?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=1650&q=80');
"
>
<h3>Ferrari</h3>
</div>
<div
class="slide"
style="
background-image: url('https://images.unsplash.com/photo-1573950940509-d924ee3fd345?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1696&q=80');
"
>
<h3>Lamborghini</h3>
</div>
<div
class="slide"
style="
background-image: url('https://images.unsplash.com/photo-1492144534655-ae79c964c9d7?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1694&q=80');
"
>
<h3>Camaro</h3>
</div>
<div
class="slide"
style="
background-image: url('https://images.unsplash.com/photo-1535732820275-9ffd998cac22?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1650&q=80');
"
>
<h3>Aston</h3>
</div>
<div
class="slide"
style="
background-image: url('https://images.unsplash.com/photo-1554744512-d6c603f27c54?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=1650&q=80');
"
>
<h3>Tesla</h3>
</div>
</div>
<script src="app.js"></script>
</body>
вот css
* {
box-sizing: border-box;
}
body {
font-family: 'Muli', sans-serif;
overflow: hidden;
margin: 0;
background: rgb(5, 19, 66);
}
.container {
padding: 0 1rem;
display: grid;
grid-template-columns: auto auto 800px auto auto;
grid-auto-flow: column dense;
gap: 1rem;
grid-auto-rows: 100vh;
align-items: center;
}
.slide {
height: 80vh;
border-radius: 20px;
cursor: pointer;
color: white;
animation: animate 7s linear infinite;
box-shadow: 0 0 30px #00ffff;
background-size: cover;
background-position: center;
background-repeat: no-repeat;
position: relative;
transition: all 500ms ease-in-out;
}
.slide h3 {
position: absolute;
margin: 0;
bottom: 1rem;
left: 1rem;
font-size: 30px;
opacity: 0;
}
.slide.active {}
.slide.active h3 {
opacity: 1;
transition: opacity 0.5 ease-in;
}
@keyframes animate {
from {
filter: hue-rotate(0deg);
}
to {
filter: hue-rotate(360deg);
}
}
вот js
const cars = document.querySelectorAll(".slide");
cars.forEach((slide) => {
slide.addEventListener("click", () => {
clearActiveClasses();
slide.classList.add("active");
});
});
function clearActiveClasses() {
cars.forEach((slide) => {
slide.classList.remove("active");
});
}