I'm trying to create a gallery, but the images are too zoomed in. How can I make them fit properly?
I've experimented with adjusting the width and height, but it's not quite right.
Here is the HTML code:
<div class="bod">
<h1 class="header1">Gallery</h1>
<div class="wrapper-gallery">
<div class="media">
<div class="layer">
<p class="para">Student: RANDOM</p>
</div>
<img src="https://images.unsplash.com/photo-1431818563807-927945852ab6?dpr=1&auto=format&fit=crop&w=1199&h=899&q=80&cs=tinysrgb&crop=" alt="" />
</div>
<div class="media">
<div class="layer">
<p class="para">Student: RANDOM</p>
</div>
<img src="https://images.unsplash.com/photo-1431818563807-927945852ab6... crop=" alt="" />
</div>
<div class="media">
<div class="layer">
<p class="para">Student: RANDOM</p>
</div>
<img src="https://images.unsplash.com/photo-1431818563807-927945852ab6...tiny... alt=""/>
</div>
</div>
</div>
</div>
Check out the CSS for the above:
<style>
@import url('https://fonts.googleapis.com/css?family=Inconsolata|Source+Sans+Pro:200,300,400,600');
.bod {
height: 100vh;
display: flex;
width: 100%;
flex-direction: column;
justify-content: center;
align-items: center;
background: #E0E0E0;
overflow: hidden;
}
.header1 {
font-family: 'Source Sans Pro', sans-serif;
font-size: 22px;
color: #151E3F;
font-weight: 300;
letter-spacing: 2px;
}
.wrapper-gallery {
display: flex;
justify-content: center;
align-items: center;
> * {
margin: 5px;
}
}
.media {
width: 300px;
height: 200px;
overflow: hidden;
position: relative;
display: flex;
justify-content: center;
align-items: center;
img {
max-width: 100%;
height: auto;
}
}
.layer {
opacity: 0;
position: absolute;
display: flex;
justify-content: center;
align-items: center;
width: 10px;
height: 90%;
background: #FFF;
color: #151E3F;
transition: all 0.9s ease;
p {
transition: all 0.9s ease;
transform: scale(0.2)
}
}
.para {
font-family: 'Inconsolata', monospace;
text-align: center;
font-size: 15px;
letter-spacing:1px;
font-size: 15px;
}
.media:hover .layer {
opacity: 0.8;
width: 95%;
transition: all 0.5s ease;
p {
transform: scale(1);
transition: all 0.9s ease;
}
}
@media (max-width: 800px){
.bod {
transform: scale(0.8);
}
}
@media (max-width: 600px) {
.wrapper-gallery {
display: block;
> * {
margin: 10px;
}
}
</style>
The issue is that the images are zoomed in too close. Does anyone know how to make them fit snugly?