I started developing a webpage using the CSS3 Grid and stumbled upon a problem I cannot seem to find a solution for.
Basically I have a container div which I populate as follows:
#pages {
margin-top: 20px;
display: grid;
grid-template-columns: repeat(auto-fit,minmax(30%,1fr));
grid-template-rows: repeat(auto-fit, minmax(300px, auto));
justify-items: stretch;
grid-gap: var(--gridgap);
grid-column: 1 / 1;
grid-row: 2;
color: black;
}
The HTML looks something like this:
<div id="pages">
<article class="pagecard">
<div class="cardheader">
<h1> Page1 </h1>
</div>
<div class="carddesc">
<p> orem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has</p>
</div>
</article>
<article class="pagecard">
<div class="cardheader">
<h1> Page2 </h1>
</div>
<div class="carddesc">
<p> Description test</p>
</div>
</article>
<article class="pagecard">
<div class="cardheader">
<h1> Page3 </h1>
</div>
<div class="carddesc">
<p> Description test</p>
</div>
</article>
...
Usually this results in 3 Containers per row. What I want to do is make a container span the whole row when it is being hovered upon.
I tried doing it like this:
.pagecard:hover{
grid-column: 1 / -1;
}
This seems to work well for the item which is in column 1. When the mouse hovers over it it will span the whole row and all other items are correctly pushed to the next.
However when I try to hover over the element in row 1 column 2, instead of being positioned to column 1 and then stretched, pushing the item to the left away into the next row, the item itself jumps to the next row. Due to this effect it loses the hover and starts "jumping" back and forth.
Is this solvable using purely CSS and HTML?
Basically, when hovering over item #2 in a grid looking like:
1 2 3
4 5 6
It should result in
2 2 2
1 3 4
6
Hope anyone can point me into the right direction.
Thanks in advance!
EDIT:
I guess this would be solvable with javascript by calculating the cell's row and then setting grid-row: currentRow additionally to grid-column. However I am interested if there is a CSS only solution!