Grid Optimization and Scaling issues - html

My 3x3 grid is not scaling as it should. Box 1, 5 and 9 contain some form of text, and the rest of them are pictures. When scaling down, the box with photos are displaying an excessive amount of white, and the ones with text are displaying an excessive amount of blue. I have no idea what is causing this to happen.
I am also looking for a way to center my text in its designated squares. Left aligned, but still centered. I have no idea how to apply both.
.grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
grid-gap: 1em;
grid-auto-rows: 1fr;
text-align: left;
color: white;
font-size: 14px;
font-family: Open Sans, sans-serif;
}
/* .grid>div {
background: #2b5eaf;
padding: 1em;
} */
/* .grid>div:nth-child(odd) {
background: #2b5eaf;
} */
.box-1,
.box-5,
.box-9 {
background: #2b5eaf;
color: white;
}
.button {
border: none;
color: white;
padding: 16px 50px;
text-align: center;
text-decoration: none;
font-size: 14px;
transition-duration: 0.4s;
cursor: pointer;
border-radius: 12px;
}
.group1 {
padding: 48px;
justify-content: center;
}
h1 {
font-size: 30px;
}
p {
font-size: 14px;
}
.box-5 {
display: flex;
flex-direction: column;
align-items: center;
}
.button2 {
background-color: white;
color: black;
border: 2px solid #008CBA;
}
.button2:hover {
background-color: #008CBA;
color: white;
}
.photo>img {
object-fit: cover;
width: 100%;
max-height: 100%;
}
.photo {
width: 100%;
height: auto;
}
/* TABLET VIEW */
#media only screen and (min-width: 759px) and (max-width: 1279px) {
.grid {
grid-template-columns: repeat(2, 1fr);
text-align: left;
grid-gap: 0;
}
.grid>div {
height: 100%;
}
.box-2,
.box-6,
.box-7 {
display: none;
}
.box-8 {
grid-column: 2;
grid-row: 3;
}
.box-9 {
grid-column: 1;
}
h1 {
font-size: 24px;
}
}
/* MOBILE VIEW */
#media only screen and (max-width: 759px) {
.grid {
grid-template-columns: 1fr 1fr;
text-align: left;
grid-gap: 0;
}
.box-1 {
grid-row: 3;
grid-column: 1/3;
}
.box-2 {
grid-row: 2;
grid-column: 1;
}
.box-3 {
grid-row: 2;
grid-column: 2;
}
.box-5 {
grid-row: 1;
grid-column: 1/3;
}
.box-7,
.box-8,
.box-9 {
display: none;
}
}
<div class="grid">
<!-- CLASS NUMBER READ LEFT TO RIGHT FROM DESKTOP VIEW -->
<div class="box-1">
<div class="group1">
<h1 class="quote" style="color:#ffffff" ;>"Lingerie is not about seducing men; It's about embracing womanhood"</h1><br><br>
<p style="color:#ffffff" ;>- Dita Von Teese</p>
</div>
</div>
<div class="box-2">
<img class="photo" src="https://i.imgur.com/p5IOrlS.png" alt="">
</div>
<div class="box-3">
<img class="photo" src="https://i.imgur.com/JKKqZjj.png" alt="">
</div>
<div class="box-4">
<img class="photo" src="https://i.imgur.com/pI3g39l.png" alt="">
</div>
<div class="box-5">
<h1 style="color:#ffffff" ;>Discover Something Sexy In You</h1>
<a class="button button2" href="https://www.subbly.co/checkout/buy/112646">Take Style Quiz</a>
</div>
<div class="box-6">
<img class="photo" src="https://i.imgur.com/2mVzhR6.png" alt="">
</div>
<div class="box-7">
<img class="photo" src="https://i.imgur.com/bIcsE4S.png" alt="">
</div>
<div class="box-8">
<img class="photo" src="https://i.imgur.com/LnUV9eF.png" alt="">
</div>
<div class="box-9">
<div class="group1">
<h1 style="color:#ffffff" ;>"My wife and I absolute LOVE our SeductiveBox subscription! This bring more excitement to our love life. Plus this is the only subscription that gets unwrapped TWICE!"</h1><br><br>
<p style="color:#ffffff" ;>- Wendy S.</p>
</div>
</div>
</div>

flex and grid works wonderfully together. Simply add display: flex; to your photos (and use proper selectors - .photo > img is not a proper selector as they are the same element - use img.photo instead). Also use height: 100%; for them to scale properly.
On the boxes where you want to center the text, use flex and its properties align-items: center; to center vertically and justify-content: center; to center horizontally.
I haven't done any styling in the media-query, you can use the same logic as above if you want.
.grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
grid-gap: 1em;
grid-auto-rows: 1fr;
text-align: left;
color: white;
font-size: 14px;
font-family: Open Sans, sans-serif;
}
/* .grid>div {
background: #2b5eaf;
padding: 1em;
} */
/* .grid>div:nth-child(odd) {
background: #2b5eaf;
} */
.box-1,
.box-5,
.box-9 {
background: #2b5eaf;
color: white;
display: flex;
align-items: center;
justify-content: center;
}
.button {
border: none;
color: white;
padding: 16px 50px;
text-align: center;
text-decoration: none;
font-size: 14px;
transition-duration: 0.4s;
cursor: pointer;
border-radius: 12px;
}
.group1 {
padding: 48px;
justify-content: center;
}
h1 {
font-size: 30px;
}
p {
font-size: 14px;
}
.box-5 {
display: flex;
flex-direction: column;
align-items: center;
}
.button2 {
background-color: white;
color: black;
border: 2px solid #008CBA;
}
.button2:hover {
background-color: #008CBA;
color: white;
}
img.photo {
display: flex;
object-fit: cover;
width: 100%;
height: 100%;
}
/*.photo {
width: 100%;
height: auto;
}*/
/* TABLET VIEW */
#media only screen and (min-width: 759px) and (max-width: 1279px) {
.grid {
grid-template-columns: repeat(2, 1fr);
text-align: left;
grid-gap: 0;
}
.grid>div {
height: 100%;
}
.box-2,
.box-6,
.box-7 {
display: none;
}
.box-8 {
grid-column: 2;
grid-row: 3;
}
.box-9 {
grid-column: 1;
}
h1 {
font-size: 24px;
}
}
/* MOBILE VIEW */
#media only screen and (max-width: 759px) {
.grid {
grid-template-columns: 1fr 1fr;
text-align: left;
grid-gap: 0;
}
.box-1 {
grid-row: 3;
grid-column: 1/3;
}
.box-2 {
grid-row: 2;
grid-column: 1;
}
.box-3 {
grid-row: 2;
grid-column: 2;
}
.box-5 {
grid-row: 1;
grid-column: 1/3;
}
.box-7,
.box-8,
.box-9 {
display: none;
}
}
</h1>
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title></title>
</head>
<body>
<div class="grid">
<!-- CLASS NUMBER READ LEFT TO RIGHT FROM DESKTOP VIEW -->
<div class="box-1">
<div class="group1">
<h1 class="quote" style="color:#ffffff" ;>"Lingerie is not about seducing men; It's about embracing womanhood"</h1><br><br>
<p style="color:#ffffff" ;>- Dita Von Teese</p>
</div>
</div>
<div class="box-2">
<img class="photo" src="https://i.imgur.com/p5IOrlS.png" alt="">
</div>
<div class="box-3">
<img class="photo" src="https://i.imgur.com/JKKqZjj.png" alt="">
</div>
<div class="box-4">
<img class="photo" src="https://i.imgur.com/pI3g39l.png" alt="">
</div>
<div class="box-5">
<h1 style="color:#ffffff" ;>Discover Something Sexy In You</h1>
<a class="button button2" href="https://www.subbly.co/checkout/buy/112646">Take Style Quiz</a>
</div>
<div class="box-6">
<img class="photo" src="https://i.imgur.com/2mVzhR6.png" alt="">
</div>
<div class="box-7">
<img class="photo" src="https://i.imgur.com/bIcsE4S.png" alt="">
</div>
<div class="box-8">
<img class="photo" src="https://i.imgur.com/LnUV9eF.png" alt="">
</div>
<div class="box-9">
<div class="group1">
<h1 style="color:#ffffff" ;>"My wife and I absolute LOVE our SeductiveBox subscription! This bring more excitement to our love life. Plus this is the only subscription that gets unwrapped TWICE!"</h1><br><br>
<p style="color:#ffffff" ;>- Wendy S.</p>
</div>
</div>
</div>
</body>
</html>

Related

Positioning grid items in navigation bar

im trying to get my "Home" and "Clock" link up inside the navigation-bar. I am clueless why the CSS i wrote doesnt solve this issue. Can someone help me out? Ive tried using the grid property for the children of the navigation-bar, but they seem to not fit. Is there a better way to do this?
<link rel="stylesheet" type="text/css" href="styles.css" />
<div class="container">
<div class="header">Home</div>
<div class="navigation">
Navigation
<ul>
<li>Home</li>
<li>Clock</li>
</ul>
</div>
<div class="content-large">
Overview
<div class="grid-item">
<form>
<button class="cal_btn" formaction="">Calendar</button>
</form>
</div>
<div class="grid-item">
<form>
<button class="cal_btn" formaction="">Show</button>
</form>
</div>
<div class="grid-item">
<form>
<button class="cal_btn" formaction="/tagung/">Add</button>
</form>
</div>
<div class="grid-item">
<form>
<button class="cal_btn" formaction="/cal/">Edit</button>
</form>
</div>
<div class="grid-item">
<form>
<button class="cal_btn" formaction="">Delete</button>
</form>
</div>
</div>
<div class="content-small">. . .</div>
<div class="content-small">. . .</div>
<div class="footer">Footer</div>
</div>
And the CSS file below
body {
margin: 0;
}
.container {
width: 100vw;
height: 100vh;
display: grid;
font-family: "Quicksand", sans-serif;
font-weight: bold;
font-size: 1.5rem;
grid-template-columns: repeat(3, 1fr);
grid-template-rows: 50px 50px 1fr 1fr 100px;
grid-gap: 0.5rem;
padding: 0.5rem;
box-sizing: border-box;
}
.header,
.navigation,
.footer,
.content-large,
.content-small {
padding: 0.5rem;
border: 1px solid black;
}
.container > .header {
grid-column: 1/4;
}
.container > .navigation {
grid-column: 1/4;
background-color: #eee;
}
.navigation ul {
display: grid;
grid-template-columns: repeat(2, 1fr);
grid-column: 1/4;
font-size: large;
}
.nav-element {
font-size: 10px;
background-color: blue;
}
.container > .content-large {
grid-row: 3 / span 2;
grid-column: 1/3;
}
.grid-item {
padding: 1px;
}
.nav-item {
grid-column: 1/3;
}
.container > .cal_btn {
transition-duration: 0.4s;
background-color: #e7e7e7;
color: black;
border: 2px solid black;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
width: 300px;
height: 100px;
}
.cal_btn:hover {
background-color: aliceblue;
color: cornflowerblue;
}
.container > .footer {
grid-column: 1/4;
}
Thanks in advance!
P.S. Ive added a link to my Codesandbox here.
The main reason why you are not getting the desired layout is that display: grid; rule for .navigation ul makes the ul a block element, which gets the whole width of its parent. There may be various ways to achieve this. A solution with minimal changes to your code is replacing display: grid; with
display: inline-grid;
width: 200px;
Of course you can adjust the width as you wish.

How to left align an image in a flex container?

I'm trying to get the image to appear on the left with content on the right.
desired output would be:
my images on the below appear above the content. I've tried a number of things with the flex-direction but just can't get the image to appear on the left.
here's my cut down code, any suggestions would be greatly appreciated.
<style>html {
background: #f5f7f8;
font-family: 'Roboto', sans-serif;
-webkit-font-smoothing: antialiased;
padding: 20px 0;
}
.band {
width: 90%;
max-width: 1240px;
margin: 0 auto;
display: grid;
grid-template-columns: 1fr;
grid-template-rows: auto;
grid-gap: 20px;
}
#media only screen and (min-width: 500px) {
.band {
grid-template-columns: 1fr 1fr;
}
.item-1 {
grid-column: 1/ span 2;
}
.item-1 h1 {
font-size: 30px;
}
}
#media only screen and (min-width: 850px) {
.band {
grid-template-columns: 1fr 1fr 1fr 1fr;
}
}
/* card */
.card {
min-height: 100%;
background: white;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
display: flex;
flex-direction: column;
text-decoration: none;
color: #444;
position: relative;
top: 0;
transition: all .1s ease-in;
}
.card:hover {
top: -2px;
box-shadow: 0 4px 5px rgba(0, 0, 0, 0.2);
}
.card article {
padding: 20px;
display: flex;
flex: 1;
justify-content: space-between;
flex-direction: column;
}
.card .thumb {
padding-bottom: 60%;
background-size: cover;
background-position: center center;
}
.card p {
flex: 1;
/* make p grow to fill available space*/
line-height: 1.4;
}
/* typography */
h1 {
font-size: 20px;
margin: 0;
color: #333;
}
.card span {
font-size: 12px;
font-weight: bold;
color: #999;
text-transform: uppercase;
letter-spacing: .05em;
margin: 2em 0 0 0;
}
</style>
<div class="support-grid"></div>
<div class="band">
<div class="item-4">
<a href="#" class="card">
<div class="thumb" style="background-image: url(https://thumbs.dreamstime.com/z/positive-pension-happiness-money-saving-retirement-financia-positive-pension-happiness-money-saving-retirement-financial-118207382.jpg);"></div>
<article>
<h1>title</h1>
<p></p>
<span>content</span>
</article>
</a>
</div>
<div class="item-5">
<a href="#" class="card">
<div class="thumb" style="background-image: url(https://thumbs.dreamstime.com/z/positive-pension-happiness-money-saving-retirement-financia-positive-pension-happiness-money-saving-retirement-financial-118207382.jpg);"></div>
<article>
<h1>title</h1>
<p></p>
<span>content</span>
</article>
</a>
</div>
<div class="item-6">
<a href="#" class="card">
<div class="thumb" style="background-image: url(https://thumbs.dreamstime.com/z/positive-pension-happiness-money-saving-retirement-financia-positive-pension-happiness-money-saving-retirement-financial-118207382.jpg);"></div>
<article>
<h1>title</h1>
<p></p>
<span>content</span>
</article>
</a>
</div>
<div class="item-7">
<a href="#" class="card">
<div class="thumb" style="background-image: url(https://thumbs.dreamstime.com/z/positive-pension-happiness-money-saving-retirement-financia-positive-pension-happiness-money-saving-retirement-financial-118207382.jpg);"></div>
<article>
<h1>title</h1>
<p></p>
<span>content</span>
</article>
</a>
</div>
</div>
Change flex-direction: column; to flex-direction: row; on card. Then you just have to define a width for thumb because you are using it as a background image. So I set width: 100%; to thumb.
html {
background: #f5f7f8;
font-family: 'Roboto', sans-serif;
-webkit-font-smoothing: antialiased;
padding: 20px 0;
}
.band {
width: 90%;
max-width: 1240px;
margin: 0 auto;
display: grid;
grid-template-columns: 1fr;
grid-template-rows: auto;
grid-gap: 20px;
}
#media only screen and (min-width: 500px) {
.band {
grid-template-columns: 1fr 1fr;
}
.item-1 {
grid-column: 1/ span 2;
}
.item-1 h1 {
font-size: 30px;
}
}
#media only screen and (min-width: 850px) {
.band {
grid-template-columns: 1fr 1fr 1fr 1fr;
}
}
/* card */
.card {
min-height: 100%;
background: white;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
display: flex;
flex-direction: row;
flex-flow: row;
text-decoration: none;
color: #444;
position: relative;
top: 0;
transition: all .1s ease-in;
}
.card:hover {
top: -2px;
box-shadow: 0 4px 5px rgba(0, 0, 0, 0.2);
}
.card article {
padding: 20px;
display: flex;
flex: 1;
justify-content: space-between;
flex-direction: column;
}
.card .thumb {
padding-bottom: 60%;
background-size: cover;
background-position: center center;
}
.card p {
flex: 1;
/* make p grow to fill available space*/
line-height: 1.4;
}
/* typography */
h1 {
font-size: 20px;
margin: 0;
color: #333;
}
.card span {
font-size: 12px;
font-weight: bold;
color: #999;
text-transform: uppercase;
letter-spacing: .05em;
margin: 2em 0 0 0;
}
.thumb {
width: 100%;
}
<div class="support-grid"></div>
<div class="band">
<div class="item-4">
<a href="#" class="card">
<div class="thumb" style="background-image: url(https://thumbs.dreamstime.com/z/positive-pension-happiness-money-saving-retirement-financia-positive-pension-happiness-money-saving-retirement-financial-118207382.jpg);"></div>
<article>
<h1>title</h1>
<p></p>
<span>content</span>
</article>
</a>
</div>
<div class="item-5">
<a href="#" class="card">
<div class="thumb" style="background-image: url(https://thumbs.dreamstime.com/z/positive-pension-happiness-money-saving-retirement-financia-positive-pension-happiness-money-saving-retirement-financial-118207382.jpg);"></div>
<article>
<h1>title</h1>
<p></p>
<span>content</span>
</article>
</a>
</div>
<div class="item-6">
<a href="#" class="card">
<div class="thumb" style="background-image: url(https://thumbs.dreamstime.com/z/positive-pension-happiness-money-saving-retirement-financia-positive-pension-happiness-money-saving-retirement-financial-118207382.jpg);"></div>
<article>
<h1>title</h1>
<p></p>
<span>content</span>
</article>
</a>
</div>
<div class="item-7">
<a href="#" class="card">
<div class="thumb" style="background-image: url(https://thumbs.dreamstime.com/z/positive-pension-happiness-money-saving-retirement-financia-positive-pension-happiness-money-saving-retirement-financial-118207382.jpg);"></div>
<article>
<h1>title</h1>
<p></p>
<span>content</span>
</article>
</a>
</div>
</div>
Start by focusing on these two areas:
In your code, the flex container is set to flex-direction: column. This makes your image and the article (i.e., the flex items) stack vertically. Remove this column setting so that the items can line up in a row (which is the default setting).
The flex container will work better if you render the item with HTML (using the img tag) as opposed to CSS (using the background-image property). It will work even better if you wrap the img in a figure, div or other HTML element, as images seem to be problematic for some browsers when they're flex items. The common solution is to make the wrapper a flex item.
.card {
display: flex;
/* flex-direction: column; */
}
div {
width: 200px;
}
img {
width: 100%;
height: auto;
}
.card article {
padding: 20px;
}
<a href="#" class="card">
<div>
<img src="https://thumbs.dreamstime.com/z/positive-pension-happiness-money-saving-retirement-financia-positive-pension-happiness-money-saving-retirement-financial-118207382.jpg">
</div>
<article>
<h1>title</h1>
<p></p>
<span>content</span>
</article>
</a>
Setting the .card class flex-direction to this:
.card {
flex-direction: row;
}
and adding: flex: 1 0 1%; width:1%; to article and .thumb should get you started.

Hover effect with a text box inside an a href image

I can't figure it out how I can fix this problem with hover effect on image with a href.
so I made 2 types of different codes. in the first image the hover effect perfect match the size of the box:
The second image not. (In the code the image 1 it's set as image background, the second one as image)
Also, if i resize the screen (mobile phone screen), the size of the first image became so little.
Can anybody help me with this code? I need only one example so I can do the same for the other a href images.
This is the code:
body {
margin: 0;
}
img {
width: 100%;
height: auto;
}
.gallery {
margin: 0 0.65rem;
}
.gallery-item {
height: auto;
margin: 0.5rem;
}
.gallery-item img {
width: 100%;
height: 100%;
object-fit: cover;
}
#media (min-width: 640px) {
.gallery {
display: grid;
grid-template-columns: repeat(3, 1fr);
grid-template-rows: repeat(5, 300px);
grid-auto-flow: row dense;
}
.gallery-item:first-child {
grid-column: 1/4;
grid-row: span 1;
}
.gallery-item:nth-child(2),
.gallery-item:nth-child(3),
.gallery-item:nth-child(4) {}
.gallery-item:nth-child(5),
.gallery-item:nth-child(6) {
grid-column: 1/2;
border: 6px solid #333;
}
.gallery-item:nth-child(7) {
grid-column: 2/3;
grid-row: 3/5;
}
.gallery-item:nth-child(10) {
grid-column: 1/3;
}
.gallery-item:nth-child(11),
.gallery-item:nth-child(13) {
border: 6px solid #333;
}
}
#media (min-width: 960px) {
.gallery {
display: grid;
grid-template-columns: repeat(3, 1fr);
grid-template-rows: repeat(5, auto);
}
.gallery-item:first-child {
grid-column: 1/4;
grid-row: span 1;
}
.gallery-item:nth-child(2),
.gallery-item:nth-child(3),
.gallery-item:nth-child(4) {}
.gallery-item:nth-child(5),
.gallery-item:nth-child(6) {
grid-column: 1/2;
border: 6px solid #333;
}
.gallery-item:nth-child(7) {
grid-column: 2/3;
grid-row: 3/5;
}
.gallery-item:nth-child(10) {
grid-column: 1/3;
}
.gallery-item:nth-child(11),
.gallery-item:nth-child(13) {
border: 6px solid #333;
}
}
.product-1 {
background-image: url("https://cdn.shopify.com/s/files/1/0425/9040/4758/products/VK_SS21-14280robeshama_600x.jpg?v=1607788637");
}
.middle {
top: 50%;
left: 50%;
text-align: center;
}
.text {
color: white;
font-size: 16px;
padding: 16px 32px;
}
*,
*::before,
*::after {
margin: 0;
padding: 0;
box-sizing: border-box;
}
.gallery-item a {
width: 100%;
height: 100%;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
position: relative;
display: flex;
align-items: center;
justify-content: center;
text-decoration: none;
}
.gallery-item a i {
color: rgba(255, 255, 255, 0.6);
font-size: 3rem;
z-index: 100;
padding: 1rem 1rem;
border: 2px solid rgba(255, 255, 255, .6);
border-radius: .4rem;
opacity: 0;
transition: opacity .5s;
}
.gallery-item a::before {
content: '';
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
background-color: rgba(0, 0, 0, .8);
opacity: 0;
transition: opacity .5s;
}
.gallery-item a:hover i,
.gallery-item a:hover::before {
opacity: 1;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title> Image Gallery </title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="gallery">
<div class="gallery-item"><img src="https://i.postimg.cc/dtRS4K2L/brigitte-bardot-1-800x400.jpg"></div>
<div class="gallery-item"><img src="https://i.postimg.cc/q7j09Dt0/schermata-2020-09-09-alle-18-35-19-1599669344.png"></div>
<div class="gallery-item"><img src="https://i.postimg.cc/j5DN1qbT/4e3f95459e0ea75731c812c6bb5b2b98.jpg"></div>
<div class="gallery-item"><img src="https://i.postimg.cc/2ySS4ZNn/okok.jpg" style="object-fit: contain"></div>
<div class="gallery-item">
<a href="https://ali-da.com/collections/dresses/products/shama-white-dress" class="product-1">
<i class="middle">
<div class="text">Discover More</div>
</i>
</a>
</div>
<div class="gallery-item">
<a href="https://ali-da.com/collections/dresses/products/short-boho-rich-dress">
<img src="https://cdn.shopify.com/s/files/1/0425/9040/4758/products/Schermata2021-04-19alle12.14.07_600x.png?v=1618827354">
<i class="middle">
<div class="text">Discover More</div>
</i>
</a>
</div>
<div class="gallery-item"><img src="https://i.postimg.cc/kgSp097x/7af20cc13f08d23f6b56bbafcba9c894.jpg"></div>
<div class="gallery-item"><img src="https://i.postimg.cc/hG6bcQMv/Brigitte-Bardot-beach-robe-red-straw-hat-1960s.jpg"></div>
<div class="gallery-item"><img src="https://i.postimg.cc/JhZtHyMG/409debab4e6404f1ba9ccd2a0caf57d5.jpg"></div>
<div class="gallery-item"><img src="https://i.postimg.cc/3xWrMtRX/port-saint-tropez-g08oplu.jpg"></div>
<div class="gallery-item">
<a href="https://ali-da.com/collections/sunglasses/products/edith">
<img src="https://cdn.shopify.com/s/files/1/0425/9040/4758/products/PELLE_1-Modifica_600x.jpg?v=1618827011">
</a>
</div>
<div class="gallery-item"><img src="https://i.postimg.cc/7LZvzWXt/A.jpg" style="object-fit: contain"></div>
<div class="gallery-item">
<a href="https://ali-da.com/collections/shoes/products/bubbles-flats">
<img src="https://cdn.shopify.com/s/files/1/0425/9040/4758/products/dhdhdhdh_400x.jpg?v=1618408909">
</a>
</div>
<div class="gallery-item"><img src="https://i.postimg.cc/bN5rw74C/6ac52adef5323f8859c853b6aeae2ebe.jpg"></div>
</div>
</body>
</html>
I've added: position: absolute; and removed left: 50%;
Properties like top, left etc has no effect when they are in static position (normal flow)
.middle {
position: absolute;
top: 50%;
text-align: center;
}
body {
margin: 0;
}
img {
width: 100%;
height: auto;
}
.gallery {
margin: 0 0.65rem;
}
.gallery-item {
height: auto;
margin: 0.5rem;
}
.gallery-item img {
width: 100%;
height: 100%;
object-fit: cover;
}
#media (min-width: 640px) {
.gallery {
display: grid;
grid-template-columns: repeat(3, 1fr);
grid-template-rows: repeat(5, 300px);
grid-auto-flow: row dense;
}
.gallery-item:first-child {
grid-column: 1/4;
grid-row: span 1;
}
.gallery-item:nth-child(2),
.gallery-item:nth-child(3),
.gallery-item:nth-child(4) {}
.gallery-item:nth-child(5),
.gallery-item:nth-child(6) {
grid-column: 1/2;
border: 6px solid #333;
}
.gallery-item:nth-child(7) {
grid-column: 2/3;
grid-row: 3/5;
}
.gallery-item:nth-child(10) {
grid-column: 1/3;
}
.gallery-item:nth-child(11),
.gallery-item:nth-child(13) {
border: 6px solid #333;
}
}
#media (min-width: 960px) {
.gallery {
display: grid;
grid-template-columns: repeat(3, 1fr);
grid-template-rows: repeat(5, auto);
}
.gallery-item:first-child {
grid-column: 1/4;
grid-row: span 1;
}
.gallery-item:nth-child(2),
.gallery-item:nth-child(3),
.gallery-item:nth-child(4) {}
.gallery-item:nth-child(5),
.gallery-item:nth-child(6) {
grid-column: 1/2;
border: 6px solid #333;
}
.gallery-item:nth-child(7) {
grid-column: 2/3;
grid-row: 3/5;
}
.gallery-item:nth-child(10) {
grid-column: 1/3;
}
.gallery-item:nth-child(11),
.gallery-item:nth-child(13) {
border: 6px solid #333;
}
}
.product-1 {
background-image: url("https://cdn.shopify.com/s/files/1/0425/9040/4758/products/VK_SS21-14280robeshama_600x.jpg?v=1607788637");
}
.middle {
position: absolute;
top: 50%;
text-align: center;
}
.text {
color: white;
font-size: 16px;
padding: 16px 32px;
}
*,
*::before,
*::after {
margin: 0;
padding: 0;
box-sizing: border-box;
}
.gallery-item a {
width: 100%;
height: 100%;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
position: relative;
display: flex;
align-items: center;
justify-content: center;
text-decoration: none;
}
.gallery-item a .middle {
color: rgba(255, 255, 255, 0.6);
font-size: 3rem;
z-index: 100;
padding: 1rem 1rem;
border: 2px solid rgba(255, 255, 255, .6);
border-radius: .4rem;
opacity: 0;
transition: opacity .5s;
}
.gallery-item a::before {
content: '';
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
background-color: rgba(0, 0, 0, .8);
opacity: 0;
transition: opacity .5s;
}
.gallery-item a:hover .middle,
.gallery-item a:hover::before {
opacity: 1;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title> Image Gallery </title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="gallery">
<div class="gallery-item"><img src="https://i.postimg.cc/dtRS4K2L/brigitte-bardot-1-800x400.jpg"></div>
<div class="gallery-item"><img src="https://i.postimg.cc/q7j09Dt0/schermata-2020-09-09-alle-18-35-19-1599669344.png"></div>
<div class="gallery-item"><img src="https://i.postimg.cc/j5DN1qbT/4e3f95459e0ea75731c812c6bb5b2b98.jpg"></div>
<div class="gallery-item"><img src="https://i.postimg.cc/2ySS4ZNn/okok.jpg" style="object-fit: contain"></div>
<div class="gallery-item">
<a href="https://ali-da.com/collections/dresses/products/shama-white-dress" class="product-1">
<div class="middle">
<i class="text">Discover More</i>
</div>
</a>
</div>
<div class="gallery-item">
<a href="https://ali-da.com/collections/dresses/products/short-boho-rich-dress">
<img src="https://cdn.shopify.com/s/files/1/0425/9040/4758/products/Schermata2021-04-19alle12.14.07_600x.png?v=1618827354">
<div class="middle">
<i class="text">Discover More</i>
</div>
</a>
</div>
<div class="gallery-item"><img src="https://i.postimg.cc/kgSp097x/7af20cc13f08d23f6b56bbafcba9c894.jpg"></div>
<div class="gallery-item"><img src="https://i.postimg.cc/hG6bcQMv/Brigitte-Bardot-beach-robe-red-straw-hat-1960s.jpg"></div>
<div class="gallery-item"><img src="https://i.postimg.cc/JhZtHyMG/409debab4e6404f1ba9ccd2a0caf57d5.jpg"></div>
<div class="gallery-item"><img src="https://i.postimg.cc/3xWrMtRX/port-saint-tropez-g08oplu.jpg"></div>
<div class="gallery-item">
<a href="https://ali-da.com/collections/sunglasses/products/edith">
<img src="https://cdn.shopify.com/s/files/1/0425/9040/4758/products/PELLE_1-Modifica_600x.jpg?v=1618827011">
</a>
</div>
<div class="gallery-item"><img src="https://i.postimg.cc/7LZvzWXt/A.jpg" style="object-fit: contain"></div>
<div class="gallery-item">
<a href="https://ali-da.com/collections/shoes/products/bubbles-flats">
<img src="https://cdn.shopify.com/s/files/1/0425/9040/4758/products/dhdhdhdh_400x.jpg?v=1618408909">
</a>
</div>
<div class="gallery-item"><img src="https://i.postimg.cc/bN5rw74C/6ac52adef5323f8859c853b6aeae2ebe.jpg"></div>
</div>
</body>
</html>

CSS Photo Gallery wGrid - Gap Problem // Margin around images

EDITED - 3x3 grid with NO GAPS solved (if images are all same size) Now, how would I do that for different sized images stored in my computer rather than online? Should I standardize the images' size BEFORE adding to code, or can is it best to resize them in HTML...I'd think CSS. When different sized images are included, how can I best get them all to the same size/dimensions? Object fit doesn't seem to do it.. The JS Fiddle and code has been updated to show the grid with one differently sized image causing problems.... From what I'd seen, a grid like the DOES NOT usually want width/height specified in the HTML but in the CSS?
I'm trying to put a 3x3 photo grid within a grid item (onearticles) which is the main content section for my website. Grid-gap, or just gap, for the gallery, is the issue. I don't know much about formatting images for web design yet, but even with this stock photo, the images have HUGE gaps between them. Please help!
I have the images in that 3x3 layout with the simple
grid-template-columns: 1fr 1fr 1fr;
and
grid-template-rows: minmax(100px, auto);
and have a tried a lot of other "responsive" variations, though, the problem persists. I don't think "onearticles" and the photo-gallery is inheriting any gaps from parent items, and I know I'll have to figure out a way to make all 9 images be the same size in their "grid," despite them not all having the same dimensions/sizes. As of now, its a repeated stock image, so same dimensions but that gap issue is the main problem
In posting the code in these different places, I see there can be a greater gap between the 1st and 2nd row than the 2nd and 3rd row because of the grid-template-rows: minmax(100px, auto); I could just switch it to auto to make those gaps vertical gaps the same, but I don't know how to parlay that into solving the overall gap issue....
My goal is to have the 3x3 photo grid to the left of wrapped text, which I don't think will be that much harder than just making the grid with NO gaps.
I've attached ALL my code below as well as a JS Fiddle. Thank you for the help and keep being awesome everyone!
* {box-sizing: border-box;}
figure {
margin: 0px;
}
.wrapper {
background-color: red;
background-position: center center;
background-repeat: no-repeat;
background-attachment: fixed;
background-size: cover;
max-width: 100%;
margin: 0;
font: 1.2em Helvetica, arial, sans-serif;
height: 100%;}
.wrapper > * {
background-color: rgba(255, 255, 255, .7);
border-radius: 5px;
padding: 0px;}
h2 {
word-wrap: normal;
}
a:hover {
font-weight: bold;
background-color: rgb(28, 224, 238);
}
.main-head {
grid-area: header;
display: grid;
gap: 0px;
text-align: center;
padding: 0px;
word-wrap: break-word;
}
.main-head h1 {
margin-top: 3vh;
margin-bottom: 3vh;
font-size: 20px;
}
.content {
grid-area: content;
display: grid;
grid-template-columns: 1fr 1fr;
grid-auto-rows: minmax(100px, auto);
gap: 10px;
height: 100%;
padding: 0px;
grid-template-areas:
"one one"
"three four";
padding-bottom: 0px;
background-color: rgba(255, 255, 255, .0);
}
.wrapper article div{
height: 100%;
background-color: rgba(255, 255, 255, .7);
border-radius: 12px;
}
.one {
grid-area: one;
word-wrap: break-word;
padding-left: 8px;
padding-top: 8px;
height: 100%;
}
.onelineup {
grid-area: one;
word-wrap: break-word;
padding-left: 8px;
padding-top: 8px;
height: 100%;
}
.onearticles {
grid-area: one;
word-wrap: break-word;
padding: 10px;
height: 100%;
}
#morsecrazy {
border-radius: 4px;
float: right;
clear: right;
margin: 7px 15px 5px 10px;
}
.onelineup img {
border-radius: 0px;
float: left;
clear: left;
margin: 7px 15px 5px 7px;
max-width: 90%;
height: auto;
}
.ad img {
width: 100%;
height: 100%;
display: block;
object-fit: contain;
}
/* Create two equal columns that floats next to each other */
.column {
float: left;
width: 50%;
padding: 10px;
height: 100%;
font-size: 2vh;
}
/* Clear floats after the columns */
.row:after {
content: "";
display: table;
clear: both;
}
.three {
grid-area: three;
height: 100%;
}
.three h4 {
margin-bottom: 1vh;
margin-top: 1vh;
}
.three ul {
list-style-type: auto;
padding-left: 20px;
padding-right: 5px;
flex-direction: row;
}
.three ul li {
padding-bottom: 15px;
display: flex;
justify-content: space-between;
flex-direction: row;
}
.four {
grid-area: four;
height: 100%;
padding: 0px;
}
.fourIFR {
overflow: hidden;
padding-top: 61.67872568688917%‬;
position: relative;
overflow: auto;-webkit-overflow-scrolling:touch;
}
.fourIFR-iframe {
border: 0;
height: 100%;
left: 0;
position: absolute;
top: 0;
width: 100%;
}
.gallery {
display: grid;
float: left;
grid-area: one;
grid-template-columns: 1fr 1fr 1fr;
grid-template-rows: auto;
gap: 0px;
border: 1px solid black;
margin: 0px;
max-height: 100%;
max-width: 50%;
padding-top: 0px;
}
.gallery__img {
display: block;
object-fit: contain;
padding: 0px;
max-width: 100%;
max-width: 100%;
}
.gallery__item--1 {
grid-column-start: 1;
grid-column-end: 2;
grid-row-start: 1;
grid-row-end: 2;
}
.gallery__item--2 {
grid-column-start: 2;
grid-column-end: 3;
grid-row-start: 1;
grid-row-end: 2;
}
.gallery__item--3 {
grid-column-start: 3;
grid-column-end: 4;
grid-row-start: 1;
grid-row-end: 2;
}
.gallery__item--4 {
grid-column-start: 1;
grid-column-end: 2;
grid-row-start: 2;
grid-row-end: 3;
}
.gallery__item--5 {
grid-column-start: 2;
grid-column-end: 3;
grid-row-start: 2;
grid-row-end: 3;
}
.gallery__item--6 {
grid-column-start: 3;
grid-column-end: 4;
grid-row-start: 2;
grid-row-end: 3;
}
.gallery__item--7 {
grid-column-start: 1;
grid-column-end: 2;
grid-row-start: 3;
grid-row-end: 4;
}
.gallery__item--8 {
grid-column-start: 2;
grid-column-end: 3;
grid-row-start: 3;
grid-row-end: 4;
}
.gallery__item--9 {
grid-column-start: 3;
grid-column-end: 4;
grid-row-start: 3;
grid-row-end: 4;
}
.main-nav {
grid-area: nav;}
.main-nav ul {
font-size: 24px;
list-style-type: none;
margin: 0;
padding: 0;}
.main-nav ul li {
padding-bottom: 0vh;}
nav ul {
margin: 0;
padding: 0;}
.side {
grid-area: sidebar;
font-size: 2.5vh;}
.side p {
margin-bottom: 0px;
padding-left: 4px;}
.ad {
grid-area: ad;
padding: 0px
}
.main-footer {
grid-area: footer;
padding: 0px;
}
.wrapper {
display: grid;
grid-gap: 15px;
grid-template-areas:
"header"
"nav"
"content"
"sidebar"
"ad"
"footer";
}
#media (min-width: 500px) {
.wrapper {
grid-template-columns: 1.5fr 4.5fr;
grid-template-areas:
"header header"
"nav nav"
"sidebar content"
"ad content"
"footer footer";
}
nav ul {
display: flex;
justify-content: space-between;
}
.onelineup img {
border-radius: 0px;
float: left;
clear: left;
margin: 7px 15px 5px 7px;
max-width: 300px;
height: auto;
}
.videoofweek {
width: 100%;
min-height: 500px;
display: block;
object-fit: contain;
}
}
#media (min-width: 700px) {
.wrapper {
grid-template-columns: 1fr 6fr 1fr;
grid-template-areas:
"header header header"
"nav content sidebar"
"nav content ad"
"footer footer footer"}
nav ul {
flex-direction: column;
}
.main-nav ul li {
padding-bottom: 5vh;
}
.onelineup img {
border-radius: 0px;
float: left;
clear: left;
margin: 7px 15px 5px 7px;
max-width: 300px;
height: auto;
}
}
<div class="wrapper">
<header class="main-head">
<h1>Baseball Website</h1>
</header>
<nav class="main-nav">
<ul>
<li>Home</li>
<li>Lineup</li>
<li>Articles</li>
<li>Vid</li>
</ul>
</nav>
<article class="content">
<div class="onearticles">
<section class="gallery">
<figure class=”gallery__item gallery__item--1">
<img src="https://images.pexels.com/photos/2115874/pexels-photo-2115874.jpeg?auto=compress&cs=tinysrgb&dpr=3&h=750&w=1260" class="gallery__img" alt="Image 1">
</figure>
<figure class="gallery__item gallery__item--2">
<img src="https://images.pexels.com/photos/1787035/pexels-photo-1787035.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940" class="gallery__img" alt="Image 2">
</figure>
<figure class="gallery__item gallery__item--3">
<img src="https://images.pexels.com/photos/2115874/pexels-photo-2115874.jpeg?auto=compress&cs=tinysrgb&dpr=3&h=750&w=1260" class="gallery__img" alt="Image 3">
</figure>
<figure class="gallery__item gallery__item--4">
<img src="https://images.pexels.com/photos/2115874/pexels-photo-2115874.jpeg?auto=compress&cs=tinysrgb&dpr=3&h=750&w=1260" class="gallery__img" alt="Image 4">
</figure>
<figure class="gallery__item gallery__item--5">
<img src="https://images.pexels.com/photos/2115874/pexels-photo-2115874.jpeg?auto=compress&cs=tinysrgb&dpr=3&h=750&w=1260" class="gallery__img" alt="Image 5">
</figure>
<figure class="gallery__item gallery__item--6">
<img src="https://images.pexels.com/photos/2115874/pexels-photo-2115874.jpeg?auto=compress&cs=tinysrgb&dpr=3&h=750&w=1260" class="gallery__img" alt="Image 6">
</figure>
<figure class="gallery__item gallery__item--7">
<img src="https://images.pexels.com/photos/2115874/pexels-photo-2115874.jpeg?auto=compress&cs=tinysrgb&dpr=3&h=750&w=1260" class="gallery__img" alt="Image 7">
</figure>
<figure class="gallery__item gallery__item--8">
<img src="https://images.pexels.com/photos/2115874/pexels-photo-2115874.jpeg?auto=compress&cs=tinysrgb&dpr=3&h=750&w=1260" class="gallery__img" alt="Image 8">
</figure>
<figure class="gallery__item gallery__item--9">
<img src="https://images.pexels.com/photos/2115874/pexels-photo-2115874.jpeg?auto=compress&cs=tinysrgb&dpr=3&h=750&w=1260" class="gallery__img" alt="Image 9">
</figure>
</section>
<h2>The Lineup</h2>
<p>Thank you so much for the help. Can get doing so much more now after what's easily been my biggest impasse thus far!</p>
</div>
<div class="three">
<h2>Articles</h2>
<ul>
<li>Y</li>
<li>A</li>
<li>D</li>
<li>A</li>
</ul>
</div>
<div class="four">
</div>
</article>
<aside class="side">
<h2>Lineup</h2>
<p>C - Dude</p>
<p>1B - Dude</p>
<p>2B - Dude</p>
<p>3B - Dude</p>
<p>SS - Dude</p>
<p>LF - Dude</p>
<p>CF - Dude</p>
<p>RF - Dude</p>
<p>DH - Dude</p>
</aside>
<div class="ad">
<p>ad</p>
</div>
<footer class="main-footer">The footer</footer>
</div>
https://jsfiddle.net/wikex004/e650oLak/29/
Your question is a bit confusing but is that what you are looking for?
I simply removed the width and height of .gallery__img and removed the padding of figure.
* {box-sizing: border-box;}
figure {
margin: 0px;
}
.wrapper {
background-color: red;
background-position: center center;
background-repeat: no-repeat;
background-attachment: fixed;
background-size: cover;
max-width: 100%;
margin: 0;
font: 1.2em Helvetica, arial, sans-serif;
height: 100%;}
.wrapper > * {
background-color: rgba(255, 255, 255, .7);
border-radius: 5px;
padding: 0px;}
h2 {
word-wrap: normal;
}
a:hover {
font-weight: bold;
background-color: rgb(28, 224, 238);
}
.main-head {
grid-area: header;
display: grid;
gap: 0px;
text-align: center;
padding: 0px;
word-wrap: break-word;
}
.main-head h1 {
margin-top: 3vh;
margin-bottom: 3vh;
font-size: 20px;
}
.content {
grid-area: content;
display: grid;
grid-template-columns: 1fr 1fr;
grid-auto-rows: minmax(100px, auto);
gap: 10px;
height: 100%;
padding: 0px;
grid-template-areas:
"one one"
"three four";
padding-bottom: 0px;
background-color: rgba(255, 255, 255, .0);
}
.wrapper article div{
height: 100%;
background-color: rgba(255, 255, 255, .7);
border-radius: 12px;
}
.one {
grid-area: one;
word-wrap: break-word;
padding-left: 8px;
padding-top: 8px;
height: 100%;
}
.onelineup {
grid-area: one;
word-wrap: break-word;
padding-left: 8px;
padding-top: 8px;
height: 100%;
}
.onearticles {
grid-area: one;
word-wrap: break-word;
padding: 10px;
height: 100%;
}
#morsecrazy {
border-radius: 4px;
float: right;
clear: right;
margin: 7px 15px 5px 10px;
}
.onelineup img {
border-radius: 0px;
float: left;
clear: left;
margin: 7px 15px 5px 7px;
max-width: 90%;
height: auto;
}
.ad img {
width: 100%;
height: 100%;
display: block;
object-fit: contain;
}
/* Create two equal columns that floats next to each other */
.column {
float: left;
width: 50%;
padding: 10px;
height: 100%;
font-size: 2vh;
}
/* Clear floats after the columns */
.row:after {
content: "";
display: table;
clear: both;
}
.three {
grid-area: three;
height: 100%;
}
.three h4 {
margin-bottom: 1vh;
margin-top: 1vh;
}
.three ul {
list-style-type: auto;
padding-left: 20px;
padding-right: 5px;
flex-direction: row;
}
.three ul li {
padding-bottom: 15px;
display: flex;
justify-content: space-between;
flex-direction: row;
}
.four {
grid-area: four;
height: 100%;
padding: 0px;
}
.fourIFR {
overflow: hidden;
padding-top: 61.67872568688917%‬;
position: relative;
overflow: auto;-webkit-overflow-scrolling:touch;
}
.fourIFR-iframe {
border: 0;
height: 100%;
left: 0;
position: absolute;
top: 0;
width: 100%;
}
.gallery {
display: grid;
grid-area: one;
grid-template-columns: 1fr 1fr 1fr;
grid-template-rows: minmax(100px, auto);
gap: 0px;
border: 1px solid black;
margin: 0px;
max-height: 100%;
max-width: 100%;
padding-top: 0px;
}
.gallery__img {
display: block;
object-fit: contain;
padding: 0px;
max-width: 100%;
max-width: 100%;
}
.gallery__item--1 {
grid-column-start: 1;
grid-column-end: 2;
grid-row-start: 1;
grid-row-end: 2;
}
.gallery__item--2 {
grid-column-start: 2;
grid-column-end: 3;
grid-row-start: 1;
grid-row-end: 2;
}
.gallery__item--3 {
grid-column-start: 3;
grid-column-end: 4;
grid-row-start: 1;
grid-row-end: 2;
}
.gallery__item--4 {
grid-column-start: 1;
grid-column-end: 2;
grid-row-start: 2;
grid-row-end: 3;
}
.gallery__item--5 {
grid-column-start: 2;
grid-column-end: 3;
grid-row-start: 2;
grid-row-end: 3;
}
.gallery__item--6 {
grid-column-start: 3;
grid-column-end: 4;
grid-row-start: 2;
grid-row-end: 3;
}
.gallery__item--7 {
grid-column-start: 1;
grid-column-end: 2;
grid-row-start: 3;
grid-row-end: 4;
}
.gallery__item--8 {
grid-column-start: 2;
grid-column-end: 3;
grid-row-start: 3;
grid-row-end: 4;
}
.gallery__item--9 {
grid-column-start: 3;
grid-column-end: 4;
grid-row-start: 3;
grid-row-end: 4;
}
.main-nav {
grid-area: nav;}
.main-nav ul {
font-size: 24px;
list-style-type: none;
margin: 0;
padding: 0;}
.main-nav ul li {
padding-bottom: 0vh;}
nav ul {
margin: 0;
padding: 0;}
.side {
grid-area: sidebar;
font-size: 2.5vh;}
.side p {
margin-bottom: 0px;
padding-left: 4px;}
.ad {
grid-area: ad;
padding: 0px
}
.main-footer {
grid-area: footer;
padding: 0px;
}
.wrapper {
display: grid;
grid-gap: 15px;
grid-template-areas:
"header"
"nav"
"content"
"sidebar"
"ad"
"footer";
}
#media (min-width: 500px) {
.wrapper {
grid-template-columns: 1.5fr 4.5fr;
grid-template-areas:
"header header"
"nav nav"
"sidebar content"
"ad content"
"footer footer";
}
nav ul {
display: flex;
justify-content: space-between;
}
.onelineup img {
border-radius: 0px;
float: left;
clear: left;
margin: 7px 15px 5px 7px;
max-width: 300px;
height: auto;
}
.videoofweek {
width: 100%;
min-height: 500px;
display: block;
object-fit: contain;
}
}
#media (min-width: 700px) {
.wrapper {
grid-template-columns: 1fr 6fr 1fr;
grid-template-areas:
"header header header"
"nav content sidebar"
"nav content ad"
"footer footer footer"}
nav ul {
flex-direction: column;
}
.main-nav ul li {
padding-bottom: 5vh;
}
.onelineup img {
border-radius: 0px;
float: left;
clear: left;
margin: 7px 15px 5px 7px;
max-width: 300px;
height: auto;
}
}
<div class="wrapper">
<header class="main-head">
<h1>Baseball Website</h1>
</header>
<nav class="main-nav">
<ul>
<li>Home</li>
<li>Lineup</li>
<li>Articles</li>
<li>Vid</li>
</ul>
</nav>
<article class="content">
<div class="onearticles">
<section class="gallery">
<figure class=”gallery__item gallery__item--1">
<img src="https://images.pexels.com/photos/2115874/pexels-photo-2115874.jpeg?auto=compress&cs=tinysrgb&dpr=3&h=750&w=1260" class="gallery__img" alt="Image 1">
</figure>
<figure class="gallery__item gallery__item--2">
<img src="https://images.pexels.com/photos/2115874/pexels-photo-2115874.jpeg?auto=compress&cs=tinysrgb&dpr=3&h=750&w=1260" class="gallery__img" alt="Image 2">
</figure>
<figure class="gallery__item gallery__item--3">
<img src="https://images.pexels.com/photos/2115874/pexels-photo-2115874.jpeg?auto=compress&cs=tinysrgb&dpr=3&h=750&w=1260" class="gallery__img" alt="Image 3">
</figure>
<figure class="gallery__item gallery__item--4">
<img src="https://images.pexels.com/photos/2115874/pexels-photo-2115874.jpeg?auto=compress&cs=tinysrgb&dpr=3&h=750&w=1260" class="gallery__img" alt="Image 4">
</figure>
<figure class="gallery__item gallery__item--5">
<img src="https://images.pexels.com/photos/2115874/pexels-photo-2115874.jpeg?auto=compress&cs=tinysrgb&dpr=3&h=750&w=1260" class="gallery__img" alt="Image 5">
</figure>
<figure class="gallery__item gallery__item--6">
<img src="https://images.pexels.com/photos/2115874/pexels-photo-2115874.jpeg?auto=compress&cs=tinysrgb&dpr=3&h=750&w=1260" class="gallery__img" alt="Image 6">
</figure>
<figure class="gallery__item gallery__item--7">
<img src="https://images.pexels.com/photos/2115874/pexels-photo-2115874.jpeg?auto=compress&cs=tinysrgb&dpr=3&h=750&w=1260" class="gallery__img" alt="Image 7">
</figure>
<figure class="gallery__item gallery__item--8">
<img src="https://images.pexels.com/photos/2115874/pexels-photo-2115874.jpeg?auto=compress&cs=tinysrgb&dpr=3&h=750&w=1260" class="gallery__img" alt="Image 8">
</figure>
<figure class="gallery__item gallery__item--9">
<img src="https://images.pexels.com/photos/2115874/pexels-photo-2115874.jpeg?auto=compress&cs=tinysrgb&dpr=3&h=750&w=1260" class="gallery__img" alt="Image 9">
</figure>
</section>
</div>
<div class="three">
<h2>Articles</h2>
<ul>
<li>Y</li>
<li>A</li>
<li>D</li>
<li>A</li>
</ul>
</div>
<div class="four">
</div>
</article>
<aside class="side">
<h2>Lineup</h2>
<p>C - Dude</p>
<p>1B - Dude</p>
<p>2B - Dude</p>
<p>3B - Dude</p>
<p>SS - Dude</p>
<p>LF - Dude</p>
<p>CF - Dude</p>
<p>RF - Dude</p>
<p>DH - Dude</p>
</aside>
<div class="ad">
<p>ad</p>
</div>
<footer class="main-footer">The footer</footer>
</div>

I cant get CSS grids to line up

I got my header to work fine, however I cant get my pictures to follow my columns. Basically in the code below I want .left and .mid to line up horizontally ( and there is going to be a 3rd picture as well) Right now they are lining up vertically. I think I might be doing something wrong with the column set up but I am not sure
#import url('https://fonts.googleapis.com/css?family=Sofia');
body {
margin: 0;
}
nav {
display: grid;
grid-template-columns: repeat(5, 1fr);
grid-auto-rows: auto;
grid-gap: 1em;
align-items: center;
text-align: center;
/*border-bottom: 4px solid black;*/
background:#0066cc;
}
#media screen and (max-width: 900px) {
nav {
grid-template-columns: 100%;
grid-template-rows: auto;
grid-gap: 1em;
}
}
.1 {
grid-column: 1;
}
.2 {
grid-column: 2;
}
.logo {
grid-column: 3;
background-image: url("images/cocinaheader.png");
background-position: center;
background-size: contain;
background-repeat: no-repeat;
height: 6vh;
}
.3 {
grid-column: 4;
}
.4 {
grid-column: 5;
}
.navLinks {
font-family: 'Sofia';
font-size: 1.2em;
text-transform: uppercase;
text-decoration: none;
color: black;
}
.navLinks:hover {
color: white;
border-left: 1px solid white;
border-right: 1px solid white;
padding: 1em 1em;
}
#twist {
color: blue;
}
banner {
padding: 1em 1em;
display: grid;
grid-template-rows: 100%;
}
.bannerlogo{
grid-row: 1;
/*background-image: url(images/banner.jpg);*/
background-position: center;
background-size: contain;
background-repeat: no-repeat;
width: 100%;
height: 100%;
}
.h1{
font-family: 'Sofia';
font-size: 1em;
text-transform: uppercase;
color: black;
}
block {
display: grid;
grid-template-columns:20% 20% 20% 20% 20%;
/*grid-auto-rows: auto;*/
grid-gap: 1em;
align-items: center;
}
.left {
grid-column: 2;
background-image: url("images/foodleft.png");
background-position: center;
background-size: contain;
background-repeat: no-repeat;
height: 20vh;
}
.mid {
grid-column: 3;
background-image: url("images/foodmid.jpg");
background-position: center;
background-size: contain;
background-repeat: no-repeat;
height: 20vh;
}
<header>
<nav class="container">
<div class="1">
Home
</div>
<div class="2">
Menu
</div>
<div class="logo">
</div>
<div class="3">
About Us
</div>
<div class="4">
Contact Me
</div>
</nav>
</header>
<br><br><br><br>
<main>
<div class="banner">
<div class="bannerlogo">
<center>
<img src="images/banner.jpg">
</center>
</div>
<br><br><br><br><br><br>
<div class="h1">
<center><h1>A taste of our menu</h1></center>
</div>
<!-- Start block grid -->
<div class="block">
<div class="left"></div>
<div class="mid"></div>
</div>
You cannot use just numbers as class names in css. Try using .item1 .item2 etc...