Hello!
I’m totally new in this web-dev world and doing the curriculums, currently just endend the flexbox one. But I wanted to try one thing.
If you’ve done that tutorial, you know that it’s a gallery displayed in the X-axis.
The thing is, I wanted to try to do the same thing but in the Y-axis (like, with 4 rows instead of 4 columns) which I thought was easy, just changing the flex direction and the height and width, but no, I’ve tried everything I know (which isn’t much) and it doesn’t seem to work.
Could anyone tell me what do I have to change in the code in order to make what I want to do? I thought I understood the flexboxes but, apparently, I didn’t --"
The HTML code is this one:
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Photo Gallery</title>
<link rel="stylesheet" href="./styles.css">
<div class="header">
<h1>CSS FLEXBOX PHOTO GALLERY</h1>
</div>
<div id="gallery">
<img src="https://cdn.freecodecamp.org/curriculum/css-photo-gallery/1.jpg"/>
<img src="https://cdn.freecodecamp.org/curriculum/css-photo-gallery/2.jpg"/>
<img src="https://cdn.freecodecamp.org/curriculum/css-photo-gallery/3.jpg"/>
<img src="https://cdn.freecodecamp.org/curriculum/css-photo-gallery/4.jpg"/>
<img src="https://cdn.freecodecamp.org/curriculum/css-photo-gallery/5.jpg"/>
<img src="https://cdn.freecodecamp.org/curriculum/css-photo-gallery/6.jpg"/>
<img src="https://cdn.freecodecamp.org/curriculum/css-photo-gallery/7.jpg"/>
<img src="https://cdn.freecodecamp.org/curriculum/css-photo-gallery/8.jpg"/>
<img src="https://cdn.freecodecamp.org/curriculum/css-photo-gallery/9.jpg"/>
<img src="https://cdn.freecodecamp.org/curriculum/css-photo-gallery/10.jpg"/>
</div>
And this is the CSS code:
-
{
box-sizing: border-box;
}
body {
margin: 0;
font-family: Arial;
background: #EBE7E7;
}
.header {
text-align: center;
padding: 32px;
background: #E0DDDD;
}
#gallery {
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: center;
align-items: center;
padding: 0 4px;
}
#gallery img {
width: 25%;
height: 300px;
object-fit: cover;
margin-top: 8px;
padding: 0 4px;
border-radius: 10px;
}
@media (max-width: 800px) {
#gallery img {
width: 50%;
}
}
@media (max-width: 800px) {
#gallery img {
width: 100%;
}
}
Thank you very much.