I have a row of overlapping cards in a row. When I move the mouse over a card, the card should be extended to the left so that the whole card is visible. Unfortunately, this effect changes the total width.
Question: What do I have to do so that the total width remains the same when hovering?
:root {
--slide-margin: 44px;
--slide-duration: 0.5s;
}
.w {
background-color: lightgray;
display: flex;
justify-content: center;
padding: 20px;
}
.w > div {
box-sizing: border-box;
padding: 10px;
width: 150px;
height: 150px;
margin-left: -75px;
transition: all var(--slide-duration) ease-out;
}
.w > div:hover{
margin-left: -75px;
margin-right: 75px;
background: black;
}
.w > div > span {
background: inherit;
background-clip: text;
color: transparent;
filter: invert(1) grayscale(1);
}
.a {
background-color: lightblue;
}
.b {
background-color: lightgreen;
}
.c {
background-color: brown;
}
.d {
background-color: purple;
}
<div class="w">
<div class="a"><span>A</span></div>
<div class="b"><span>B</span></div>
<div class="c"><span>C</span></div>
<div class="d"><span>D</span></div>
</div>