I have the following HTML and CSS as shown at the end.
If I remove all reference to the gridImages class (in both HTML and CSS, and directly refer to .area1 thru .area5), all works as expected (that is the images are displayed, with one in the middle and the others surrounding it).
But when I use the the HTML/CSS as shown the images are displayed in a line down the screen.
It appears that the CSS is working though as the opacity (on hover and not), rotate (on hover) etc. all work as expected.
It just looks like the 'display: grid' no longer works when you use the div class in the way I am.
Any ideas what I am doing wrong?
Thank you.
* {
box-sizing: border-box;
margin: 0;
}
body {
background: #9A9696;
margin: 10px;
}
body {
display: grid;
grid-template-columns: repeat(6, 125px);
grid-template-rows: repeat(6, 125px);
grid-template-areas:
"area1 area1 ..... ..... area2 area2"
"area1 area1 ..... ..... area2 area2"
"..... ..... area3 area3 ..... ....."
"..... ..... area3 area3 ..... ....."
"area4 area4 ..... ..... area5 area5"
"area4 area4 ..... ..... area5 area5";
justify-content: center;
}
.gridImages img {
/* display: grid;*/
background: #DE6449;
align-items: center;
justify-content: center;
border-radius: 50%;
opacity: 0.5;
margin: auto;
transition: 250ms; /* this allows a smooth "unhover" */
}
.gridImages img:hover {
opacity: 1.0;
transform: rotate(-10deg);
bottom: 50px;
transition: 250ms;
}
.area1 {grid-area: area1;}
.area2 {grid-area: area2;}
.area3 {grid-area: area3;}
.area4 {grid-area: area4;}
.area5 {grid-area: area5;}
<div class="gridImages">
<img class="area1" src="https://source.unsplash.com/248x248">
<img class="area2" src="https://source.unsplash.com/249x249">
<img class="area3" src="https://source.unsplash.com/250x250">
<img class="area4" src="https://source.unsplash.com/251x251">
<img class="area5" src="https://source.unsplash.com/252x252">
</div>