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>
Related
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.
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
I have a basic html markup, where i am trying to use minimal html wrappers to achieve the design.
The button on the bottom should't align, it should always stay in the bottom.
So my goal is without adding more html wrappers, using flex, force a flex item(button) to drop to the next line. and the block title stay next to the image.
You can see what i mean checking it on mobile breakpoints.
Here are the screenshots with flex-wrap: wrap
And here is with flex-wrap: nowrap
As you see, in first example button is in the bottom as it should be, but block title is dropped to the next line, And in the second example (flex-wrap: wrap) block title is positioned correct, but the button is not in the bottom.
Here is the sandbox link and code example
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;
/* //try nowrap */
width: 100%;
}
.logo-image {
align-self: flex-start;
}
.headline {
color: white;
}
.text {
color: white;
font-size: 16px;
margin-bottom: 20px;
}
.btn {
display: flex;
width: 100%;
}
button {
align-items: center;
background-color: black;
color: white;
flex: 0 0 100%;
justify-content: center;
margin: 0;
}
<div class="container">
<img src="download.png" width="50px" class="logo-image" alt="img" />
<span class="content">
<h4 class="headline">
Block Title
</h4>
<p class="text">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Sapiente
aliquid sit, cupiditate
</p>
</span>
<div class="btn">
<button>link</button>
</div>
</div>
Any help will be appreciated
You can make your span a block level element and set flex-grow to 1 but set flex-basis to something small, like 50% so it tries to be 50% of the width but will grow to fit the width. It then means when shrinking it will try to stay on the same line.
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%;
}
/* added this --v */
.content {
display: block;
flex: 1 0 50%;
}
.logo-image {
align-self: flex-start;
}
.headline {
color: white;
}
.text {
color: white;
font-size: 16px;
margin-bottom: 20px;
}
.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">
<img src="https://www.fillmurray.com/200/200" width="50px" class="logo-image" alt="img" />
<span class="content">
<h4 class="headline">
Block Title
</h4>
<p class="text">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Sapiente
aliquid sit, cupiditate
</p>
</span>
<div class="btn">
<button>link</button>
</div>
</div>
I am having a problem understanding how CSS grid works.
I want 3 columns side by side with a specific width and height, but there's a gap between each columns.
.grid-container {
display: grid;
grid-template-columns: 1fr 1fr 1fr;
grid-template-rows: 1fr;
grid-column-gap: 0px;
}
.left {
grid-column: 1;
border: 1px solid red;
height: 500px;
width: 300px;
}
.middle {
grid-column: 2;
border: 1px solid red;
height: 500px;
width: 300px;
}
.right {
grid-column: 3;
border: 1px solid red;
height: 500px;
width: 300px;
}
<div class="grid-container">
<div class="left">1</div>
<div class="middle">2</div>
<div class="right">3</div>
</div>
In which way I can put away this gap? And if anyone can explain me how to reduce the line of code in css I would be grateful, thanks!
EDIT
I solved in this way
.wrapper{
display: grid;
place-items: center;
min-height: 100vh;
}
.grid-container{
margin: 0 auto;
display: grid;
grid-template-columns: 1fr 1fr 1fr;
grid-template-rows: 1fr;
grid-column-gap: 0px;
width: 60vw;
height: 450px;
}
.left{
background-color: hsl(31, 77%, 52%);
grid-column: 1;
border-top-left-radius: 10px;
border-bottom-left-radius: 10px;
}
.middle{
background-color: hsl(184, 100%, 22%);
grid-column: 2;
}
.right{
background-color: hsl(179, 100%, 13%);
grid-column: 3;
border-top-right-radius: 10px;
border-bottom-right-radius: 10px;
}
<div class="wrapper">
<div class="grid-container">
<div class="left">
<img src="images/icon-sedans.svg" alt="sedans" class="logo">
<h2 class="text-title">Sedans</h2>
<div class="main-text">
Choose a sedan for its affordability and excellent fuel economy. Ideal for cruising in the city
or on your next road trip.
</div>
<button class="btn">Learn More</button>
</div>
<div class="middle">
<img src="images/icon-suvs.svg" alt="sedans" class="logo">
<h2 class="text-title">Suvs</h2>
<div class="main-text">
Take an SUV for its spacious interior, power, and versatility. Perfect for your next family vacation
and off-road adventures.
</div>
<button class="btn">Learn More</button>
</div>
<div class="right">
<img src="images/icon-luxury.svg" alt="sedans" class="logo">
<h2 class="text-title">Luxury</h2>
<div class="main-text">
Cruise in the best car brands without the bloated prices. Enjoy the enhanced comfort of a luxury
rental and arrive in style.
</div>
<button class="btn">Learn More</button>
</div>
</div>
</div>
But now what I want to do is to make all of this to be responsive
Specify your width on your grid parent, remove any static width on your child elements. With the fraction set in grid-template-columns: 1fr 1fr 1fr; each column will take up a third of the parents width. So if your parent is set to say 80 view width => 80% of the view port, then your columns will spread out over a third of that width each.
If you have had 4 items each set to 1fr, then they would take up 25%, 5 would take up 20%, basically => number of children elements/parents width.
.grid-container {
margin: auto;
display: grid;
grid-template-columns: 1fr 1fr 1fr;
grid-template-rows: 1fr;
grid-column-gap: 0;
width: 80vw;
}
.left>ul {
height: 80%;
background: pink;
display: flex;
flex-direction: column;
justify-content: space-around;
align-items: space-between;
}
.left {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
border: 1px solid red;
grid-column: 1;
}
.middle {
padding: 5px;
grid-column: 2;
border: red solid 1px;
}
.middle span {
display: flex;
flex-direction: column;
justify-content: start;
padding: 5px;
grid-column: 2;
background: lightblue;
border-bottom: 1px solid black;
}
.right {
grid-column: 3;
border: 1px solid red;
padding: .2rem;
display: flex;
flex-direction: column;
justify-content: space-around;
}
.row {
padding: 0 1rem;
display: flex;
justify-content: space-between;
align-items: start;
background: #EEE;
}
.right div:nth-of-type(2) {
color: #a2a2a2;
text-align: center;
}
<div class="grid-container">
<div class="left">Here is some content for column 1 with list items
<ul>
<li>
display: flex
</li>
<li>
flex-direction: column
</li>
<li>
justify-content: space-around
</li>
<li>
align-items: flex-start
</li>
</ul>
</div>
<div class="middle">
<span>This is inside a span tag</span>
<span>Parent has flex direction of column</span>
<span>Justify Content set at start</span>
<span>this is inside a span tag</span> More content for column 2. it is a bit longer than the first textual content. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum viverra pulvinar tincidunt. Nam consequat metus et cursus auctor.
Suspendisse posuere sem ut tortor lacinia, nec tempor turpis ultrices. Sed vitae gravida orci.</div>
<div class="right">
<div class="row">
<h3>Row</h3>
<h3>Space</h3>
<h3>Between</h3>
</div>
<span>Parents flex <span style="background: pink;">flex-direction </span> and <span style="background: pink;">display-flex</span> <b>flex</b> and <b>column</b></span></span>
<span>Parents flex <span style="background: pink;">justify-content</span> is set to <b>space-around</b></span>
<div>Good ole text-align: center... Vestibulum viverra pulvinar tincidunt. Nam consequat metus et cursus auctor. Suspendisse posuere sem ut tortor lacinia, nec tempor turpis ultrices.
</div>
</div>
</div>
Example of vertically centering text with flex-direction set to column.
body {
margin: 0;
padding: 0;
}
.parent {
text-align: center;
display: flex;
flex-direction: column;
justify-content: center;
height: 100vh;
}
.child {
margin: 0 auto;
height: 200px;
width: calc(200px - 1rem);
background: lightblue;
display: flex;
flex-direction: column;
justify-content: center;
padding: .5rem;
}
<div class="parent">
<div class="child">Vertically centering using flex.
<br><br> Justify content when parents flex-direction is set to column, will center content vertically.</div>
</div>
You can simply specify the widths that you need in the grid-template-columns property. There is no gap visible between columns.
If you want the red borders you can specify a common class for those divs and just do it once.
.grid-container{
display: grid;
grid-template-columns: 300px 300px 300px;
grid-template-rows: 1fr;
column-gap: 0;
height: 500px;
}
.left{
border: 1px solid red;
}
.middle{
border: 1px solid red;
}
.right{
border: 1px solid red;
}
<div class="grid-container">
<div class="left">1</div>
<div class="middle">2</div>
<div class="right">3</div>
</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