Why does my website create extra space when adding elements in HTML? - html

When I proceed to add elements like images, or more words in the lorem ipsum generator, it seems like some space is created. I have not had any luck finding it in the inspect mode. Also occurs when adding an image. But the example shown occurs when using for example the lorem ipsum generator, creating 100 words, and suddenly there spawns space all over the place.
* {
padding: 0;
margin: 0;
box-sizing: border-box;
}
.header {
grid-area: 1 / 1 / 2 / 6;
display: flex;
justify-content: center;
background-image: linear-gradient(141deg, #1fc8db 51%, #2cb5e8 75%);
color: white;
font-family: 'Montserrat', sans-serif;
font-size: 30px;
height: fit-content;
padding: 25px 0;
border-bottom: solid white 2px;
}
.menu {
grid-area: 2 / 1 / 3 / 6;
background-image: linear-gradient(141deg, #1fc8db 51%, #2cb5e8 75%);
height: fit-content;
padding: 20px 0;
}
ul {
list-style-type: none;
text-decoration: none;
width: 100%;
text-align: center;
}
.menu li {
padding-left: 30px;
padding-right: 30px;
}
li {
display: inline;
}
ul li a {
color: white;
text-decoration: none;
font-size: 24px;
}
ul li a:hover {
text-decoration: underline;
}
.side {
grid-area: 3 / 1 / 5 / 2;
}
.main {
grid-area: 3 / 2 / 5 / 6;
float: left;
display: flex;
justify-content: left;
}
.side,
.main {
padding: 10px;
}
.footer {
grid-area: 5 / 1 / 6 / 6;
display: flex;
justify-content: center;
}
.grid-container {
display: grid;
grid-template-columns: repeat(5, 1fr);
grid-template-rows: repeat(5, 1fr);
grid-column-gap: 0px;
grid-row-gap: 0px;
}
<div class="grid-container">
<div class="header">Øving 1</div>
<div class="menu">
<ul>
<li>Hjem</li>
<li>Om oss</li>
<li>Kontakt</li>
<li>Bestill</li>
</ul>
</div>
<div class="side">
<h3>Side</h3>
<p>Lorem, ipsum dolor sit amet consectetur adipisicing elit. Error suscipit nesciunt quos porro ex dignissimos unde officia. Similique, molestiae cum ullam quam placeat quisquam sunt ratione suscipit officiis, soluta dolorem.</p>
</div>
<div class="main">
<div class="p">
<h3>Content</h3>
<p>test</p>
</div>
<div class="img">
</div>
</div>
<div class="footer">
<h2>Copyright © Erik Skjellevik 2022</h2>
</div>
</div>

You must change that in CSS file:
//OLD
.grid-container {
display: grid;
grid-template-columns: repeat(5, 1fr);
grid-template-rows: repeat(5, 1fr);
grid-column-gap: 0px;
grid-row-gap: 0px;
}
//NEW
.grid-container {
display: grid;
}

According to my knowledge the space creation is by default property of the software so because of this your website create extra space. But to solve this problem you can use margin and padding = 0 after that no space will be created
in your website

The extra space is by default property. For fixing it, set the margin and padding to 0.
OR
For different resolutions, use media queries and for different pixels, you have to set it.

Related

Start 3rd Element from second column in flex container

I have a basic html markup, where i am trying to use minimal html wrappers to achieve the design.
So my goal is without adding more html wrappers, using flex, force 3rd flex item to start from second column like here
1 2
3
Of course, we can achieve adding padding/margin-left for the 3rd element, but I am looking for a solution with css flex and using minimal html markup.
Here is the screenshot what I am trying to achieve
Basically the title and text should start from the same column.
See the code snippet and sandbox link, if you want to test it more
body {
margin: 0;
padding: 0;
}
.container {
background-color: grey;
overflow: auto;
padding: 20px;
align-items: center;
display: flex;
position: relative;
column-gap: 15px;
flex-wrap: wrap;
width: 100%;
}
.content {
display: flex;
flex-wrap: wrap;
}
.logo-image {
align-self: flex-start;
padding-top: 10px;
order: 1;
}
.headline {
color: white;
order: 2;
padding-left: 10px;
}
.text {
color: white;
font-size: 16px;
margin-bottom: 20px;
order: 3;
}
.btn {
display: flex;
width: 100%;
}
button {
align-items: center;
background-color: black;
color: white;
flex: 0 0 90%;
justify-content: center;
margin: 0;
}
<div class="container">
<div class="content">
<h4 class="headline">
Block Title
</h4>
<img src="https://www.fillmurray.com/200/200" width="50px" class="logo-image" alt="img" />
<p class="text">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Sapiente
aliquid sit, cupiditate
</p>
</div>
<div class="btn">
<button>click</button>
</div>
Ideally, you would use CSS Grid for this layout.
Something like this (no changes to the HTML):
.container {
display: flex;
flex-wrap: wrap;
background-color: grey;
column-gap: 15px;
padding: 20px;
}
.content {
display: grid;
grid-template-columns: 50px 1fr;
}
.logo-image {
padding-top: 10px;
order: 1;
}
.headline {
color: white;
order: 2;
padding-left: 10px;
}
.text {
grid-column: 2;
color: white;
font-size: 16px;
margin-bottom: 20px;
order: 3;
}
.btn {
display: flex;
width: 100%;
}
button {
align-items: center;
background-color: black;
color: white;
flex: 0 0 90%;
justify-content: center;
margin: 0;
}
body {
margin: 0;
padding: 0;
}
<div class="container">
<div class="content">
<h4 class="headline">
Block Title
</h4>
<img src="https://www.fillmurray.com/200/200" width="50px" class="logo-image" alt="img" />
<p class="text">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Sapiente aliquid sit, cupiditate
</p>
</div>
<div class="btn">
<button>click</button>
</div>
But if you can only use flex, then you'll have to:
Define a height on the container.
Set the flex-direction to column.
Set flex-wrap to wrap.
Give the first column (containing the image) full height, so it creates a column and forces its siblings into the second column.
(Again, no changes to the HTML.)
.container {
display: flex;
flex-wrap: wrap;
background-color: grey;
column-gap: 15px;
padding: 20px;
height: 200px; /* new (for demo purposes) */
}
.content {
display: flex;
flex-direction: column; /* new */
flex-wrap: wrap;
}
.logo-image {
flex-basis: 100%; /* new */
object-fit: contain; /* new (for proper image rendering) */
object-position: top; /* new (for proper image rendering) */
align-self: flex-start;
padding-top: 10px;
order: 1;
}
.headline {
color: white;
order: 2;
padding-left: 10px;
}
.text {
color: white;
font-size: 16px;
margin-bottom: 20px;
order: 3;
}
.btn {
display: flex;
width: 100%;
}
button {
align-items: center;
background-color: black;
color: white;
flex: 0 0 90%;
justify-content: center;
margin: 0;
}
body {
margin: 0;
padding: 0;
}
<div class="container">
<div class="content">
<h4 class="headline">Block Title</h4>
<img src="https://www.fillmurray.com/200/200" width="50px" class="logo-image" alt="img" />
<p class="text">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Sapiente
aliquid sit, cupiditate
</p>
</div>
<div class="btn">
<button>click</button>
</div>
If you can't define a height on the container, then use the Grid version.
/* added this --v */
.content {
display: grid; /* ----- new ------- */
grid-template-columns: auto 1fr; /* ----- new ------- */
grid-template-rows: 1fr 1fr; /* ----- new ------- */
column-gap: 15px; /* ----- new ------- */
}
<body>
<div class="container">
<div class="content">
<!-- bring the img element above of h4 because we want it to be in the first item of our grid layout -->
<img src="download.png" width="50px" class="logo-image" alt="img" />
<h4 class="headline">
Block Title
</h4>
<p class="text">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Sapiente
aliquid sit, cupiditate
</p>
</div>
<div class="btn">
<button>link</button>
</div>
</div>
</body>
1.you need to use a two-dimensional layout which is grid (instead of flexbox)
2.you need to use grid for the element that has .content class
.content { display: grid; grid-template-columns: auto 1fr; grid-template-rows: 1fr 1fr; column-gap: 15px; } <br>
3.you need to define the p element that has .text class to start from the 2nd column and ends in the 3rd column with this code: grid-column: 2/3;
and here is the result : https://codesandbox.io/s/brave-zhukovsky-7g12bj?file=/style.css:566-583

What is the thing under (-) button that is stretching in vertical direction when the single-card div is stretch?

I don't know where that box thingy comes from under the (-) button. It stretches when the single-card div becomes bigger. When I take out rating div from the single-card div, there is no box thingy under the (-) button. Can anyone please help? Thank you.
I don't know where that box thingy comes from under the (-) button. It stretches when the single-card div becomes bigger. When I take out rating div from the single-card div, there is no box thingy under the (-) button. Can anyone please help? Thank you.
*,*::before, *::after {
margin: 0;
padding: 0;
box-sizing: border-box;
--violet: #8F00FF;
--usernamecolor: rgb(43, 72, 83);
}
.single-card {
margin-top: 60px;
display: flex;
justify-content: center;
background-color: white;
}
.rating {
border-radius: 8px;
width: 35px;
background-color: #f0f0f0;
display: flex;
flex-direction: column;
align-items: center;
box-shadow: -5px 0px 8px rgba(172, 169, 169, 0.1);
overflow: hidden;
margin-right: 15px;
}
button {
border: none;
height: 30px;
border-radius: 8px;
align-items: center;
color: var(--violet);
font-weight: bold;
cursor: pointer;
opacity: 0.7;
}
button:hover {
color: purple;
opacity: 1;
}
.rating span {
height: 30px;
display: flex;
justify-content: center;
align-items: center;
color: var(--violet);
font-weight: bold;
}
.wrapper {
width: 800px;
padding: 8px;
}
.top {
display: flex;
align-content: center;
justify-content: space-between;
}
.top .top-left {
display: flex;
}
.top img {
width: 40px;
border-radius: 100%;
margin-right: 15px;
border: 1px solid blue;
}
.top .username {
padding-top: 5px;
margin-bottom: 1px;
margin-right: 10px;
font-weight: bold;
color: var(--usernamecolor);
}
.top .date {
padding-top: 5px;
margin-bottom: 1px;
opacity: 0.8;
}
.top button {
background-color: white;
display: flex;
align-items: center;
}
<div class="single-card">
<div class="rating">
<button>+</button>
<span>12</span>
<button>-</button>
</div>
<div class="wrapper">
<div class="top">
<div class="top-left">
<div><img src="photo.jpg" alt=""></div>
<p class="username">amyrobson</p>
<p class="date">1 month ago</p>
</div>
<button><box-icon name='reply'></box-icon>Reply</button>
</div>
<p>Lorem ipsum dolor, sit amet consectetur adipisicing elit. Vero at ut facere. Quae eos soluta nesciunt perspiciatis neque a ipsa omnis eligendi nemo quidem similique, autem minima? Facilis, voluptatibus voluptatum.</p>
</div>
</div>
The - display: flex on .single-card is the cause, in the flexbox container if some items are taller than others, all items will stretch along the cross axis to fill its full size.
add to the container(.single-card): align-items: center / start / end (choose one option as it feet’s your design)
you can read more about it - https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Flexible_Box_Layout/Basic_Concepts_of_Flexbox

CSS grids layout adjustment to the content

I'm trying to set my grid layout as follows:
Is it even possible? The issue I'm having is when the content in item #3 is getting bigger it expands item #2 and pushes it down. Is there any way to avoid such behavior when content is large at item #3?
.container {
display: grid;
grid-template-columns: 200px 200px;
height: 400px;
width: 400px;
background-color: teal;
}
.grid-element {
display: grid;
place-items: center;
border: 1px solid tomato;
background-color: wheat;
font-size: 24px;
}
<div class='container'>
<div class='grid-element'>1</div>
<div class='grid-element'>2</div>
<div class='grid-element'>3</div>
</div>
example code for responsive grid with css.repeat(auto-fit, minmax(100px, 1fr)); and overflow-wrap: break-word; added for fit content.
<style>
.item1 {
grid-area: area1;
}
.item2 {
grid-area: area2;
}
.item3 {
grid-area: area3;
}
.grid-container {
display: grid;
grid-template-areas: 'area1 area1 area1 area2 area2'
'area1 area1 area1 area2 area2'
'area1 area1 area1 area3 area3'
'area1 area1 area1 area3 area3';
grid-gap: 10px;
grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
background-color: #2196F3;
padding: 10px;
overflow-wrap: break-word;
}
.grid-container > div {
background-color: rgba(255, 255, 255, 0.8);
text-align: center;
padding: 20px 0;
font-size: 30px;
}
</style>
<div class="grid-container">
<div class="item1">3</div>
<div class="item2">2</div>
<div class="item3">1</div>
</div>
I'm not sure whether I have understood your question correctly or not, but I hope the following snippet could be helpful:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.container {
width: 200px;
height: 200px;
display: grid;
grid-template-columns: repeat(2, 1fr);
grid-template-rows: repeat(2, 1fr);
grid-template-areas: "d1 d3" "d2 d3";
}
.container>div:nth-child(1) {
grid-area: d1;
}
.container>div:nth-child(2) {
grid-area: d2;
}
.container>div:nth-child(3) {
grid-area: d3;
overflow: auto;
}
</style>
</head>
<body>
<div class="container">
<div style="background-color: blue;">item1</div>
<div style="background-color: yellow;">item2</div>
<div style="background-color: orangered;">Lorem ipsum dolor sit amet consectetur adipisicing elit. Voluptatum facere facilis reprehenderit corporis, iure dolorum harum suscipit ratione fuga iste rem laboriosam aut perspiciatis libero nostrum praesentium? Quae, illum sed?</div>
</div>
</body>
</html>

Css Grid Nested Divs - Bottom Row of Nested Divs won't fill Larger Div

I'm fairly new to web design but have been trying to get a baseball research website up which has finally brought me around to code. I put in the CSS grid layout to some success but have had a persistent bug with my nested item or main content on my "Home" Page. It keeps coming up or looming large with other tasks on the site and needs to be corrected. These boards are great and I'd appreciate any help. Thank you. Here's the issue and code:
I have a responsive layout that uses media queries for 3 different screen sizes >700px, <500px and <700 px. In my main center column, there is the 2x2 "content" div which has 4 grid areas within it. The issue is, the bottom row of nested divs does not extend to the bottom of the parent div, which is exasperated when divs get to certain heights.
In the attached picture, you can see the border of the larger "content" div in black with the nested semi-transparent white nested divs stopping well before the black border. Margin-bottom has been set to 0 in about any css class I can think of. Code attached as well, but I'm also new at the intensive code post here so don't know the best way to do it :) Loving coding so far. Thanks all!
* {
box-sizing: border-box;
}
.wrapper {
background-image: url(oceanfull.PNG);
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>* {
border: 2px solid black;
background-color: rgba(255, 255, 255, .7);
border-radius: 5px;
padding: 0px;
}
.wrapper h1 {
font-size: 30px;
text-align: center;
padding: 0px;
}
a:hover {
text-decoration: underline;
background-color: rgb(28, 224, 238);
}
.main-head {
grid-area: header;
background-image: url(ray.png);
display: grid;
grid-auto-rows: minmax(100px, auto);
height: 15vh;
grid-template-columns: 1fr 4fr 1fr;
gap: 0px;
padding: 0px;
grid-template-areas: "leftop centertop righttop";
}
.main-head h1 {
margin-top: 50px;
margin-bottom: 0px;
background-color: blue;
border: solid black;
}
.leftop {
grid-area: leftop;
border: solid green;
}
.lefttop img {
height: 40%;
width: 100%;
position: relative;
top: 60%;
right: 10%;
}
.centertop {
grid-area: centertop;
display: flex;
flex-direction: row;
margin: auto;
position: relative;
top: -50%;
}
.righttop {
grid-area: righttop;
}
.righttop img {
height: 60%;
width: 100%;
position: relative;
top: 40%;
}
.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.0);
border: solid black;
}
.wrapper article div {
height: 100%;
border: 1px solid black;
background-color: rgba(255, 255, 255, 0.7);
border-radius: 12px;
}
.one {
grid-area: one;
word-wrap: break-word;
padding-left: 8px;
padding-top: 8px;
height: 100%;
}
.one img {
border-radius: 12px;
float: right;
clear: right;
}
.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;
}
.three ul li {
padding-bottom: 15px;
}
.four {
grid-area: four;
height: 100%;
}
.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;
}
}
#media (min-width: 700px) {
.wrapper {
grid-template-columns: 1fr 4fr 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;
}
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>BBsite</title>
<link rel="stylesheet" href="stylesheet.css">
</head>
<body>
<div class="wrapper">
<header class="main-head">
<div class="lefttop">
</div>
<div class="centertop">
<h1>The Site</h1>
</div>
<div class="righttop">
</div>
</header>
<nav class="main-nav">
<ul>
<li>Home</li>
<li>Lineup</li>
<li>Articles</li>
</ul>
</nav>
<article class="content">
<div class="one">
<img src="morsecrazy.jpg" alt="morsecrazy">
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Eaque, nemo minus ad nisi debitis a in aliquam reiciendis iure libero vero totam laboriosam quidem, animi esse, itaque doloribus dolore culpa doloremque. Maxime soluta laboriosam commodi,
itaque facilis qui doloremque aliquid non quisquam placeat eveniet ipsum fugiat voluptates culpa ad dolor?</p>
<p>Lorem ipsum dolor, sit amet consectetur adipisicing elit. Eligendi adipisci ipsam facere veritatis fugit error ab fugiat! Ea, illum laudantium?</p>
<p>Lorem ipsum dolor, sit amet consectetur adipisicing elit. Eligendi adipisci ipsam facere veritatis fugit error ab fugiat! Ea, illum laudantium?</p>
</div>
<div class="three">
<h4>The Old Recent Research/Articles/Charts</h4>
<ul>
<li>Data Thing</li>
<li>You Won't Believe Thing</li>
<li>Article Thing</li>
<li>Thing Another</li>
<li>Thing</li>
</ul>
</div>
<div class="four">4</div>
</article>
<aside class="side">
<h2>Lineup</h2>
<p>C - Guy Catcher</p>
<p>1B - First Basemanman</p>
<p>2B - Double Base</p>
<p>3B - 3B</p>
<p>SS - The Shortstop</p>
<p>LF - Left the what?</p>
<p>CF - Rover</p>
<p>RF - Bobby Abreu</p>
<p>DH - DH</p>
</aside>
<div class="ad">
<p>ad</p>
</div>
<footer class="main-footer">The footer</footer>
</div>
HTML:
<article class="content">
  <div class="one">
<img src="morsecrazy.jpg" alt="morsecrazy">
<p>Loremssss<p>
</div>
<div class="three">
<h4>The Old Recent Research/Articles/Charts</h4>
<ul>
<li>Data Thing</li>
<li>You Won't Believe Thing</li>
<li>Article Thing</li>
<li>Thing Another</li>
<li>Thing</li>
</ul>
</div>
<div class="four">4</div>
</article>
CSS:
.content {
grid-area: content;
display: grid;
grid-template-columns: 1fr 1fr;
grid-auto-rows: minmax(100px, auto);
gap: 10px;
padding: 0px;
grid-template-areas:
"one one"
"three four";
padding-bottom: 0px;
background-color: rgba(255, 255, 255, .0);
border: solid black;}
.one {
grid-area: one;
word-wrap: break-word;
padding-left: 8px;
padding-top: 8px;
height: 100%;
}
.one img {
border-radius: 12px;
float: right;
clear: right;
}
.three {
grid-area: three;
}
.three h4 {
margin-bottom: 1vh;
margin-top: 1vh;
}
.three ul {
list-style-type: auto;
padding-left: 20px;
padding-right: 5px;
}
.three ul li {
padding-bottom: 15px;
}
.four {
grid-area: four;
}
.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;}
}
#media (min-width: 700px) {
.wrapper {
grid-template-columns: 1fr 4fr 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;}
}
Solutions/Things I've tried that haven't worked:
-Is height 100% in a certain class a problem or lacking somewhere?
-list-style type in .three ul?
-My Media Queries have a different split of Rows/Columns than what's written in the "content" CSS class?**(big one)
-other weak remedies :)
**The very presence of "grid-areas" for that nested div is maybe unnecessary or the problem? Initially, the 2x2 grid I wanted there wouldn't fill the top left div and just shift everything one, so I made the grid-areas within grid areas----but there are different layouts for the media query/Responsive layout?
So in short, why aren't the nested divs "three" and "four" filling up the entirety of their div? Its margin-bottom really want to be 0! Thank you. Please let me know if I can provide anything to assist.
IMAGE!!!! nested divs "three" and "four" don't fill their parent div (border of larger div in black)
You might have missed setting property height: 100% in div with class "three" and class "four".
The issue seemed to be in the HTML of the code. I've now posted a "Run Code Snippet" that should differ from what I originally pasted in.
Indentation or formatting issues in the HTML seemed to be the issue (?). I ran my code through JS Fiddle to post here, and the "Scrub" option I believe minorly altered the formatting of my HTML and I guess worked! Apologies for the squished CSS code }s, but I didn't want to post a super tall post. That wasn't the issue though. Indenting of items in the HTML i guess resulted in a nested div not fully filling its nest?
Thank you all

how to make row across multiple css3 columns same height?

I am trying to learn CSS grid, I have nested CSS grid and in which the parent CSS grid container has multiple columns each of them have 4 rows and I want the rows to be equal to each other for example height of the first row in the first column equal to the that in a second column.
#product-grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
grid-gap: 1em;
justify-items: center;
padding: 1em;
}
#product-grid img {
width: 100%;
height: 291px;
}
.product-item {
display: grid;
/* grid-auto-rows:1fr; */
grid-template-rows: 70px, 100px, 200px, 100px;
border-style: solid;
border-color: #2c4251;
border-width: 1px;
border-radius: 5px;
padding: 1em;
}
.cntnt {
text-align: justify;
overflow: hidden;
}
.product-item {}
.more {
text-align: left;
align-self: end;
}
.ttl {
margin-top: 20px;
text-align: center;
align-self: flex-start;
}
<div id="product-grid">
<div class='product-item'>
<img src=imgs/1.png>
<div class='ttl'>this is test title</div>
<div class='cntnt'>this is test caption</div>
<div class='more'>
<div><a href=/view.php?pid=1>more </a></div>
</div>
</div>
<div class='product-item'><img src=imgs/2.jpg>
<div class='ttl'>title</div>
<div class='cntnt'>Lorem ipsum dolor, sit amet consectetur adipisicing elit. Dolores, inventore? Officia perferendis</div>
<div class='more'>
<div><a href=/view.php?pid=2>more </a></div>
</div>
</div>
</div>