Simple grid design causing cls, Avoid major layout shifts cls - html

I am trying to create a simple grid block with minimal css but it causes cls problem, The tags that are causing cumulative layout shift: h3, img, div, p, almost all of the block.
I tried to add more css to that tags but couldn't find a way to solve it.
First div is larger than other two divs and last two divs has same size
My codes are as follows:
.grid-section {
display: grid;
grid-template-columns: repeat(3, 48% 25% 25%);
grid-gap: 1%;
margin-bottom: 40px;
}
.grid-section img {
width: 100%;
margin-bottom: 20px;
}
.grid-section h3 {
margin-bottom: 5px;
}
.grid-section a {
display: inline-block;
padding-top: 10px;
color: #0067b8;
text-transform: uppercase;
font-weight: bold;
}
.grid-section a:hover i {
margin-left: 10px;
}
#media(max-width: 768px) {
.grid-section {
grid-template-columns: repeat(2, 1fr);
}
.grid-section :first-child {
grid-column: 1 / -1;
}
}
#media(max-width: 500px) {
.grid-section {
grid-template-columns: 1fr;
}
}
<section class="grid-section">
<div>
<img src="bvvvvvvvvvv/1.webp" class="img-fluid" alt="" width="100%" height="100%" />
<h3>Save $150 + free controller</h3>
<p>
Buy an Xbox One X console and double your fun with a free select
extra controller. Starting at $349.
</p>
Learn More <i class="fas fa-chevron-right"></i>
</div>
<div>
<img src="bvvvvvvvvvv/1.webp" class="img-fluid" alt="" width="100%" height="100%" />
<h3>Save $150 + free controller</h3>
<p>
Buy an Xbox One X console and double your fun with a free select
extra controller. Starting at $349.
</p>
Learn More <i class="fas fa-chevron-right"></i>
</div>
<div>
<img src="bvvvvvvvvvv/2.webp" class="img-fluid" alt="" width="100%" height="100%" />
<h3>The new Microsoft Edge</h3>
<p>
Expect more. World class performance, with more privacy, more
productivity, and more value.
</p>
Learn More <i class="fas fa-chevron-right"></i>
</div>
</section>
Any help will be appreciated. Thanks

ok with your demo, I better see what you are looking for.
simplest solution would be to use background image for the div which contain the image and the text. This solution already needs more structure in your html, but if you want to go with "img" tag, html structure will be at least 2 times more complex.
look at the snippet and try it in mobile view.
.grid-section {
display: grid;
grid-template-columns: repeat(3, 48% 25% 25%);
grid-gap: 1%;
margin-bottom: 40px;
}
.grid-section>div {
position: relative;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
min-height: 400px;
}
.grid-section .content {
position: absolute;
left: 0;
right: 0;
bottom: 0;
padding: 1em;
margin: 1em;
background-color: rgba(255, 255, 255, 0.5);
}
.grid-section h3 {}
.grid-section a {
display: inline-block;
padding-top: 10px;
color: #0067b8;
text-transform: uppercase;
font-weight: bold;
}
.grid-section a:hover i {
margin-left: 10px;
}
#media (max-width: 768px) {
.grid-section {
grid-template-columns: repeat(2, 1fr);
}
.grid-section :first-child {
grid-column: 1 / -1;
}
}
#media (max-width: 500px) {
.grid-section {
grid-template-columns: 1fr;
}
}
<section class="grid-section">
<div style="background-image: url('https://picsum.photos/id/20/800/600')">
<div class="content">
<h3>Save $150 + free controller</h3>
<p>
Buy an Xbox One X console and double your fun with a free select extra controller. Starting at $349.
</p>
Learn More <i class="fas fa-chevron-right"></i>
</div>
</div>
<div style="background-image: url('https://picsum.photos/id/32/800/600')">
<div class="content">
<h3>Save $150 + free controller</h3>
<p>
Buy an Xbox One X console and double your fun with a free select extra controller. Starting at $349.
</p>
Learn More <i class="fas fa-chevron-right"></i>
</div>
</div>
<div style="background-image: url('https://picsum.photos/id/43/800/600')">
<div class="content">
<h3>The new Microsoft Edge</h3>
<p>
Expect more. World class performance, with more privacy, more productivity, and more value.
</p>
Learn More <i class="fas fa-chevron-right"></i>
</div>
</div>
</section>

Related

How to resize first auto column in grid?

I am trying to resize first column in grid searched on google but couldnt find the solution.
I can do it with css but want to learn how to resize repeated columns in grid.
I want first card to be width: 50%; and other two cards width:25%; and width:25%;
Here is my codes
.slider-cards {
display: grid;
grid-template-columns: repeat(3, 1fr);
grid-gap: 20px;
margin-bottom: 40px;
}
.slider-cards img {
width: 100%;
margin-bottom: 20px;
}
.slider-cards h3 {
margin-bottom: 5px;
}
.slider-cards a {
display: inline-block;
padding-top: 10px;
color: #0067b8;
text-transform: uppercase;
font-weight: bold;
}
.slider-cards a:hover i {
margin-left: 10px;
}
<div class="slider-cards">
<div class="first">
<img src="https://i.ibb.co/LZPVKq9/card1.png" alt="">
<h3>The Conversation has reported</h3>
<p>
COVID-19 has had a deeply unequal impact on UK society, affecting some communities substantially more than others.
</p>
Learn More <i class="fas fa-chevron-right"></i>
</div>
<div class="second">
<img src="https://i.ibb.co/LZPVKq9/card1.png" alt="">
<h3>The Conversation has reported</h3>
<p>
COVID-19 has had a deeply unequal impact on UK society, affecting some communities substantially more than others.
</p>
Learn More <i class="fas fa-chevron-right"></i>
</div>
<div class="third">
<img src="https://i.ibb.co/LZPVKq9/card1.png" alt="">
<h3>The Conversation has reported</h3>
<p>
COVID-19 has had a deeply unequal impact on UK society, affecting some communities substantially more than others.
</p>
Learn More <i class="fas fa-chevron-right"></i>
</div>
</div>
:

How to place divs in CSS grid using grid-template-areas?

I am trying to put similar groups of elements in a grid:
#grid {
position: absolute;
left: 135px;
top: 158px;
width: 1080px;
height: 1035px;
display: grid;
grid-template-rows: 99px 1fr 1fr;
grid-template-columns: 1fr 1fr 1fr;
grid-row-gap: 60px;
grid-column-gap: 60px;
grid-template-areas: "headings headings headings"
"content-a content-b content-c"
"content-d content-e content-f";
}
#welcome-heading {
padding-bottom: 10px;
}
#introduction-heading {
padding-bottom: 10px;
}
#headings-section {
grid-area: headings;
}
#content-a {
grid-area: content-a;
}
#content-b {
grid-area: content-b;
}
#content-c {
grid-area: content-c;
}
#content-d {
grid-area: content-d;
}
#content-e {
grid-area: content-e;
}
#content-f {
grid-area: content-f;
}
#content {
text-align: center;
}
#content img {
margin-bottom: 33px;
width: 320px;
height: 240px;
}
#content h4 {
margin-bottom: 20px;
}
.content-title-anchor {
font-size: 18px;
line-height: 18px;
color: #333333;
}
.button {
font-size: 16px;
line-height: 27px;
color: #FFFFFF;
background-color: #FF5A43;
padding: 10px 25px;
border-radius: 4px;
}
<div id="grid">
<section id="headings-section">
<h1 id="welcome-heading">Welcome to Icon Utopia!</h1>
<h3 id="introduction-heading">Everything about iconography and building your career as a designer.</h3>
<p>👇Wondering where to start?👇</p>
</section>
<section id="content">
<div id="content-a">
<img src="index/landing-page.jpg" alt="Guide to: Building your dribbble following.">
<a class="content-title-anchor" href="build-your-dribbble-audience.html">Build Your Dribbble Audience</a>
<h4>A Comprehensive Guide to Building your Dribbble following.</h4>
<a class="button" href="build-your-dribbble-audience.html">Get a FREE Chapter!</a>
</div>
<div id="content-b">
<img src="index/icon-design-guide2-1.jpg" alt="LEARN ICON DESIGN">
<a class="content-title-anchor" href="free-icon-design-guide.html">Free Icon Design Guide</a>
<h4>Everything you need to know about icon design to get started.</h4>
<a class="button" href="free-icon-design-guide.html">Learn Icon Design</a>
</div>
<div id="content-c">
<img src="index/pixel-perfect-icons.jpg" alt="CRAFTING PIXEL PERFECT ICONS">
<a class="content-title-anchor" href="crafting-pixel-perfect-icons-the-right-way.html">Pixel Perfect Course</a>
<h4>Crafting Pixel Perfect Icons The Right Way - learn to create sharp-looking icons!</h4>
<a class="button" href="crafting-pixel-perfect-icons-the-right-way.html">Check out the Course</a>
</div>
<div id="content-d">
<img src="index/space-noise-brushes.jpg" alt="SPACE NOISE: PROCREATE BRUSH SET">
<a class="content-title-anchor" href="https://gumroad.com/l/ojcK">Space Noise Brushes</a>
<h4>Procreate brushes that give your drawings fantastic textures</h4>
<a class="button" href="https://gumroad.com/l/ojcK">Get Noise Brushes</a>
</div>
<div id="content-e">
<img src="index/free-icons.jpg" alt="FREE ICONS">
<a class="content-title-anchor" href="https://iconutopia.com/free-icons/">Free Icons</a>
<h4>Best FREE vector icons and icon sets for personal and commercial use</h4>
<a class="button" href="https://iconutopia.com/free-icons/">Get Free Icons</a>
</div>
<div id="content-f">
<img src="index/icon-utopia-blog-2.jpg" alt="MY BLOG: ICON UTOPIA">
<a class="content-title-anchor" href="blog.html">Icon Utopia Blog</a>
<h4>Blog about making a steady income and building a career as an icon designer.</h4>
<a class="button" href="blog.html">Check out the Blog</a>
</div>
</section>
</div>
But this is the result that I get:
As you can see, the layout is correct for the first row. But the bottom 2 rows should each have 3 columns. Instead, I get 6 rows with one column. I've read this and I think it might have something to do with me nesting the element of each area within a div, but I'm not sure. I can't figure out what I'm supposed to do to get each of the div placed in one 'area' in a grid whose bottom 2 rows have 3 columns each.
Since your content-* elements are not direct children, they are not affected by the #grid parent. You can make your #content element a grid parent.
I changed the grid-template-areas for your #grid element and update the CSS to include styles for the #content element (which you may need to update for your needs)
#grid {
position: absolute;
left: 135px;
top: 158px;
width: 1080px;
height: 1035px;
display: grid;
grid-template-rows: 99px 1fr;
grid-template-columns: 1fr;
grid-row-gap: 60px;
grid-template-areas: "headings" "content"
}
#content {
display: grid;
width: 100%;
display: grid;
grid-template-rows: repeat(2, 1fr);
grid-template-columns: repeat(3, 1fr);
grid-row-gap: 60px;
grid-column-gap: 60px;
grid-template-areas: "content-a content-b content-c" "content-d content-e content-f";
grid-area: content;
}
#welcome-heading {
padding-bottom: 10px;
}
#introduction-heading {
padding-bottom: 10px;
}
#headings-section {
grid-area: headings;
}
#content-a {
grid-area: content-a;
}
#content-b {
grid-area: content-b;
}
#content-c {
grid-area: content-c;
}
#content-d {
grid-area: content-d;
}
#content-e {
grid-area: content-e;
}
#content-f {
grid-area: content-f;
}
#content {
text-align: center;
}
#content img {
margin-bottom: 33px;
width: 320px;
height: 240px;
}
#content h4 {
margin-bottom: 20px;
}
.content-title-anchor {
font-size: 18px;
line-height: 18px;
color: #333333;
}
.button {
font-size: 16px;
line-height: 27px;
color: #FFFFFF;
background-color: #FF5A43;
padding: 10px 25px;
border-radius: 4px;
}
<div id="grid">
<section id="headings-section">
<h1 id="welcome-heading">Welcome to Icon Utopia!</h1>
<h3 id="introduction-heading">Everything about iconography and building your career as a designer.</h3>
<p>👇Wondering where to start?👇</p>
</section>
<section id="content">
<div id="content-a">
<img src="index/landing-page.jpg" alt="Guide to: Building your dribbble following.">
<a class="content-title-anchor" href="build-your-dribbble-audience.html">Build Your Dribbble Audience</a>
<h4>A Comprehensive Guide to Building your Dribbble following.</h4>
<a class="button" href="build-your-dribbble-audience.html">Get a FREE Chapter!</a>
</div>
<div id="content-b">
<img src="index/icon-design-guide2-1.jpg" alt="LEARN ICON DESIGN">
<a class="content-title-anchor" href="free-icon-design-guide.html">Free Icon Design Guide</a>
<h4>Everything you need to know about icon design to get started.</h4>
<a class="button" href="free-icon-design-guide.html">Learn Icon Design</a>
</div>
<div id="content-c">
<img src="index/pixel-perfect-icons.jpg" alt="CRAFTING PIXEL PERFECT ICONS">
<a class="content-title-anchor" href="crafting-pixel-perfect-icons-the-right-way.html">Pixel Perfect Course</a>
<h4>Crafting Pixel Perfect Icons The Right Way - learn to create sharp-looking icons!</h4>
<a class="button" href="crafting-pixel-perfect-icons-the-right-way.html">Check out the Course</a>
</div>
<div id="content-d">
<img src="index/space-noise-brushes.jpg" alt="SPACE NOISE: PROCREATE BRUSH SET">
<a class="content-title-anchor" href="https://gumroad.com/l/ojcK">Space Noise Brushes</a>
<h4>Procreate brushes that give your drawings fantastic textures</h4>
<a class="button" href="https://gumroad.com/l/ojcK">Get Noise Brushes</a>
</div>
<div id="content-e">
<img src="index/free-icons.jpg" alt="FREE ICONS">
<a class="content-title-anchor" href="https://iconutopia.com/free-icons/">Free Icons</a>
<h4>Best FREE vector icons and icon sets for personal and commercial use</h4>
<a class="button" href="https://iconutopia.com/free-icons/">Get Free Icons</a>
</div>
<div id="content-f">
<img src="index/icon-utopia-blog-2.jpg" alt="MY BLOG: ICON UTOPIA">
<a class="content-title-anchor" href="blog.html">Icon Utopia Blog</a>
<h4>Blog about making a steady income and building a career as an icon designer.</h4>
<a class="button" href="blog.html">Check out the Blog</a>
</div>
</section>
</div>
You can technically remove the grid display from #grid since you don't necessarily need it, since your #headings-section is full-width anyway.
#grid {
position: absolute;
left: 135px;
top: 158px;
width: 1080px;
height: 1035px;
}
#content {
display: grid;
width: 100%;
display: grid;
grid-template-rows: repeat(2, 1fr);
grid-template-columns: repeat(3, 1fr);
grid-row-gap: 60px;
grid-column-gap: 60px;
grid-template-areas: "content-a content-b content-c" "content-d content-e content-f";
}
#welcome-heading {
padding-bottom: 10px;
}
#introduction-heading {
padding-bottom: 10px;
}
#headings-section {
grid-area: headings;
}
#content-a {
grid-area: content-a;
}
#content-b {
grid-area: content-b;
}
#content-c {
grid-area: content-c;
}
#content-d {
grid-area: content-d;
}
#content-e {
grid-area: content-e;
}
#content-f {
grid-area: content-f;
}
#content {
text-align: center;
}
#content img {
margin-bottom: 33px;
width: 320px;
height: 240px;
}
#content h4 {
margin-bottom: 20px;
}
.content-title-anchor {
font-size: 18px;
line-height: 18px;
color: #333333;
}
.button {
font-size: 16px;
line-height: 27px;
color: #FFFFFF;
background-color: #FF5A43;
padding: 10px 25px;
border-radius: 4px;
}
<div id="grid">
<section id="headings-section">
<h1 id="welcome-heading">Welcome to Icon Utopia!</h1>
<h3 id="introduction-heading">Everything about iconography and building your career as a designer.</h3>
<p>👇Wondering where to start?👇</p>
</section>
<section id="content">
<div id="content-a">
<img src="index/landing-page.jpg" alt="Guide to: Building your dribbble following.">
<a class="content-title-anchor" href="build-your-dribbble-audience.html">Build Your Dribbble Audience</a>
<h4>A Comprehensive Guide to Building your Dribbble following.</h4>
<a class="button" href="build-your-dribbble-audience.html">Get a FREE Chapter!</a>
</div>
<div id="content-b">
<img src="index/icon-design-guide2-1.jpg" alt="LEARN ICON DESIGN">
<a class="content-title-anchor" href="free-icon-design-guide.html">Free Icon Design Guide</a>
<h4>Everything you need to know about icon design to get started.</h4>
<a class="button" href="free-icon-design-guide.html">Learn Icon Design</a>
</div>
<div id="content-c">
<img src="index/pixel-perfect-icons.jpg" alt="CRAFTING PIXEL PERFECT ICONS">
<a class="content-title-anchor" href="crafting-pixel-perfect-icons-the-right-way.html">Pixel Perfect Course</a>
<h4>Crafting Pixel Perfect Icons The Right Way - learn to create sharp-looking icons!</h4>
<a class="button" href="crafting-pixel-perfect-icons-the-right-way.html">Check out the Course</a>
</div>
<div id="content-d">
<img src="index/space-noise-brushes.jpg" alt="SPACE NOISE: PROCREATE BRUSH SET">
<a class="content-title-anchor" href="https://gumroad.com/l/ojcK">Space Noise Brushes</a>
<h4>Procreate brushes that give your drawings fantastic textures</h4>
<a class="button" href="https://gumroad.com/l/ojcK">Get Noise Brushes</a>
</div>
<div id="content-e">
<img src="index/free-icons.jpg" alt="FREE ICONS">
<a class="content-title-anchor" href="https://iconutopia.com/free-icons/">Free Icons</a>
<h4>Best FREE vector icons and icon sets for personal and commercial use</h4>
<a class="button" href="https://iconutopia.com/free-icons/">Get Free Icons</a>
</div>
<div id="content-f">
<img src="index/icon-utopia-blog-2.jpg" alt="MY BLOG: ICON UTOPIA">
<a class="content-title-anchor" href="blog.html">Icon Utopia Blog</a>
<h4>Blog about making a steady income and building a career as an icon designer.</h4>
<a class="button" href="blog.html">Check out the Blog</a>
</div>
</section>
</div>

Changing the grid layout from 4 columns to 2 columns messes up the cells order

I am trying to transform a grid layout from a 4 columns into a 2 columns by using a media query. The issue is that if and when I do that the grid messes up with the items order.
Actually it works as it was designed to: it takes the HTML elements and places them from left to right into their own cell accordingly, but this "sorting" isn't good for me.
I've written the HTML elements for a 4 column grid and it only works this way.
<article class="page_1">
<div class="short_info">
<div class="info info1"></div>
<div class="info info2"></div>
<div class="info info3"></div>
<div class="info info4"></div>
<span>EASY TO USE</span>
<span>DETAILED STATISTICS</span>
<span>EASY TO CUSTOMIZE</span>
<span>SECURITY</span>
<p>You don't have to be a computer nerd to use LPR.</p>
<p>You will always have all the necessary data at your disposal. Properly used, LPR never fails.
</p>
<p>You want a special feature? Tell us about it and we'll implement it.</p>
<p> No one can delete or change data in your program. Every action a user takes in LPR is recorded in a log file.
</p>
</div>
</article>
.short_info {
display: grid;
width: 95vw;
grid-template-columns: repeat(4, 25%);
grid-template-rows: auto;
min-height: 300px;
justify-content: space-between;
align-items: space-around;
margin-bottom: 50px;
letter-spacing: 0.5px;
}
.short_info .info {
width: 5em;
height: 5em;
border-radius: 50%;
margin: 0 auto;
background-color: #eeeeee;
background-position: center;
background-repeat: no-repeat;
background-size: 50%;
}
.short_info .info1 {
background-image: url(../img/laptop.svg);
}
.short_info .info2 {
background-image: url(../img/bar-chart.svg);
}
.short_info .info3 {
background-image: url(../img/pen.svg);
}
.short_info .info4 {
background-image: url(../img/shield.svg);
}
.short_info span {
font-size: 1.5em;
}
.short_info p {
padding: 0 10px;
line-height: 25px;
}
I've designed it like this because this way I could align all the rows perfectly. The icons are aligned to each other, the spans are aligned to each other and the paragraphs are aligned to each other. There isn't one span or p that is placed lower or upper than its neighbor. They go like this:
icon icon icon icon
span span span span
p p p p
Unfortunately, this design does not allow me to simply use media queries and change to grid-template-columns: repeat(2, 50%);, because this will display the information in a messed up order. It will go like this:
icon icon
icon icon
span span
span span
p p
p p
which is not pretty at all.
I've thought of another way of designing this, but I can't get the items to perfectly align.
I've put one icon, one span, and one p inside a div and made a grid with just only one row.
I've used flex to try and align the elements inside the div but I can't align them on the same line as I previously did.
<div class="short_info">
<div>
<div class="info info1"></div>
<span>EASY TO USE</span>
<p>You don't have to be a computer nerd to use Metrici LPR.</p>
</div>
<div>
<div class="info info2"></div>
<span>DETAILED STATISTICS</span>
<p>
You will always have all the necessary data at your disposal. Properly used, Metrici LPR never fails.
</p>
</div>
<div>
<div class="info info3"></div>
<span>EASY TO CUSTOMIZE</span>
<p>You want a special feature? Tell us about it and we'll implement it.</p>
</div>
<div>
<div class="info info4"></div>
<span>SECURITY</span>
<p>
No one can delete or change data in your program. Every action a user takes in Metrici LPR is recorded in a
log file.
</p>
</div>
</div>
.short_info {
margin-bottom: 100px;
display: grid;
width: 95vw;
grid-template-columns: repeat(6, 1fr);
grid-template-rows: auto;
min-height: 200px;
}
.short_info div {
display: flex;
flex-direction: column;
justify-content: space-between;
align-items: center;
}
.short_info .info {
width: 5em;
height: 5em;
border-radius: 50%;
margin: 0 auto;
background-color: #eeeeee;
background-position: center;
background-repeat: no-repeat;
background-size: 50%;
}
this allows me to properly resize them from 4 columns to 2 when I resize the window, but it will align the elements inside independently, not on the same rows like the previous grid.
The new alignment looks like this:
icon icon icon icon
span span
span
span
p p
p
p
The elements get aligned by flex depending on the height and width of each individual element.
I basically have two questions at this time:
How can I go from 4 columns to 2 columns using the first layout ?
How can I align all of the flex items on the same lines ?
it's possible to modify ur template to a 2 column template, if you add some HTML and change the CSS a little.
For the first question, check this code:
.short_info {
display: grid;
width: 95vw;
grid-template-columns: repeat(4, 50%);
grid-template-rows: auto;
min-height: 300px;
justify-content: space-between;
align-items: space-around;
margin-bottom: 50px;
letter-spacing: 0.5px;
grid-template-areas:
"info1 info2"
"span1 span2"
"p1 p2"
"info3 info4"
"span3 span4"
"p3 p4";
}
.short_info .info {
width: 5em;
height: 5em;
border-radius: 50%;
margin: 0 auto;
background-color: #eeeeee;
background-position: center;
background-repeat: no-repeat;
background-size: 50%;
width: 50%;
}
.short_info .info1 {
background-image: url(../img/laptop.svg);
grid-area: info1;
}
.short_info .info2 {
background-image: url(../img/bar-chart.svg);
grid-area: info2;
}
.short_info .info3 {
background-image: url(../img/pen.svg);
grid-area: info3;
}
.short_info .info4 {
background-image: url(../img/shield.svg);
grid-area: info4;
}
.short_info span {
font-size: 1.5em;
}
.short_info p {
padding: 0 10px;
line-height: 25px;
}
.span1 {
grid-area: span1;
}
.span2 {
grid-area: span2;
}
.span3 {
grid-area: span3;
}
.span4 {
grid-area: span4;
}
.p1 {
grid-area: p1;
}
.p2 {
grid-area: p2;
}
.p3 {
grid-area: p3;
}
.p4 {
grid-area: p4;
}
<article class="page_1">
<div class="short_info">
<div class="info info1"></div>
<div class="info info2"></div>
<div class="info info3"></div>
<div class="info info4"></div>
<span class="span1">EASY TO USE</span>
<span class="span2">DETAILED STATISTICS</span>
<span class="span3">EASY TO CUSTOMIZE</span>
<span class="span4">SECURITY</span>
<p class="p1">You don't have to be a computer nerd to use LPR.</p>
<p class="p2">You will always have all the necessary data at your disposal. Properly used, LPR never fails.
</p>
<p class="p3">You want a special feature? Tell us about it and we'll implement it.</p>
<p class="p4"> No one can delete or change data in your program. Every action a user takes in LPR is recorded in a log file.
</p>
</div>
</article>
For the second question (the better option, in my opinion):
you have to set fix height values for the headlines to get all stuff on a line.
Like this:
.short_info {
margin-bottom: 100px;
display: grid;
width: 95vw;
grid-template-columns: repeat(6, 1fr);
grid-template-rows: auto;
min-height: 200px;
}
.short_info div {
display: flex;
flex-direction: column;
justify-content: flex-start;
align-items: center;
}
.short_info .info {
width: 5em;
height: 5em;
border-radius: 50%;
margin: 0 auto;
background-color: #eeeeee;
background-position: center;
background-repeat: no-repeat;
background-size: 50%;
}
.short_info span {
height: 35px;
}
<div class="short_info">
<div>
<div class="info info1"></div>
<span>EASY TO USE</span>
<p>You don't have to be a computer nerd to use Metrici LPR.</p>
</div>
<div>
<div class="info info2"></div>
<span>DETAILED STATISTICS</span>
<p>
You will always have all the necessary data at your disposal. Properly used, Metrici LPR never fails.
</p>
</div>
<div>
<div class="info info3"></div>
<span>EASY TO CUSTOMIZE</span>
<p>You want a special feature? Tell us about it and we'll implement it.</p>
</div>
<div>
<div class="info info4"></div>
<span>SECURITY</span>
<p>
No one can delete or change data in your program. Every action a user takes in Metrici LPR is recorded in a
log file.
</p>
</div>
</div>

CSS Grid image and column issue in Chrome

In Chrome, my site is breaking on desktop and mobile.
Issues:
The second section isn't displaying the hero image correctly. The image should have two halves that when hovered, join together.
Hero images jump to the top of the page with only half of the image in view.
When I went to inspect the page, I saw the following in the console
[Deprecation] Percentages row tracks and gutters for indefinite height grid containers will be resolved against the intrinsic height instead of being treated as auto and zero respectively
I looked into it and came to find the fix for the said issue was to change percentages in grid-template-rows or grid-auto-rows to auto.
I applied the given fix and the issue still persisted. It only breaks in Google Chrome. The site looks fine in Firefox.
Here's the code.
HTML:
<section class="page">
<div class="details">
<h1>Skyline KPGC110</h1>
<h2>1973</h2>
</div>
<div class="hero">
<a href="./kenmeri.html">
<img class="model-left" src="./images/front-1.png" alt="model">
<img class="model-right" src="./images/front-2.png" alt="model">
</a>
</div>
</section>
<!-- ------------------------------ Seciton 2 ------------------------------ -->
<section class="page about">
<div class="details">
<h1>Skyline PGC10</h1>
<h2>1969</h2>
</div>
<div class="hero">
<a href="./pgc10.html">
<img class="model-left" src="./images/gtr-left.png" alt="chef">
<img class="model-right" src="./images/gtr-right.png" alt="chef">
</a>
</div>
</section>
<!-- ------------------------------ Section 3 ------------------------------ -->
<section class="page reel">
<div class="details">
<h1>Fairlady 240z</h1>
<h2>1973</h2>
</div>
<div class="hero">
<a href="./fairladyz.html">
<img class="model-left" src="./images/240z-left.jpg" alt="model">
<img class="model-right" src="./images/240z-right.jpg" alt="model">
</a>
</div>
</section>
Desktop view:
.page {
display: grid;
grid-template-columns: 5% 1fr 1fr 1fr 5%;
min-height: 90vh;
}
.about,
.reel {
position: absolute;
bottom: 0%;
left: 0%;
width: 100%;
opacity: 0;
pointer-events: none;
}
.hero {
display: flex; /* gets rid of gap between imgs */
align-self: center;
justify-self: center;
height: 500px;
overflow: hidden;
}
.hero a {
display: flex; /* removes seperation created by a tag */
}
.hero img {
height: 500px;
transition: transform 0.3s ease-out;
cursor: pointer;
}
Breakpoint 1(Laptop):
#media screen and (max-width: 1024px) {
.page {
grid-template-columns: 5% 1fr 5%;
grid-template-rows: 2fr 1fr;
align-items: center;
}
.hero {
height: auto;
grid-column: 2;
}
.hero img {
height: 425px;
}
}
Breakpoint 2(Mobile):
#media screen and (max-width: 768px) {
.page {
grid-template-rows: 1fr;
}
.page-1 h3 {
font-size: 1.125rem;
padding-right: 20px;
}
.hero img {
width: auto;
}
.details h2 {
font-size: 28px;
}
}
The link to the repo is here if you want to get a full look at the code.
In your code,
img {
display: block;
width: 100%;
height: 100%;
}
just remove the width: 100% and it will work fine.

Undesired Column Layout HTML/CSS

I have a CSS layout problem. In the Portfolio section of my site # 763px breakpoint I want 3 rows with 2 columns in each of them. I have that.
[.col] [.col]
[.col] [.col]
[.col] [.col]
But from 926px - 978px my columns break up and then i get 4 rows like this:
[.col] [.col]
[.col]
[.col] [.col]
[.col]
Why is this happening? And what is the solution? Thank you.
main {
margin: 55px 0px -30px 0px;
background: linear-gradient(transparent, rgba(102, 194, 255, 0.4) 10%, transparent 99%);
padding-bottom: 5rem;
}
h2 {
text-align: center;
margin: 5rem 0;
font-size: 1.6rem;
}
h3 {
color: #353535;
font-size: 1.3rem;
margin: 1.2rem 0;
}
.col {
width: 100%;
text-align: center;
margin-bottom: 15px;
}
.col p {
width: 90%;
margin: 0 auto;
}
.col img {
width: 95%;
}
/*====== 768px ==== */
#media (min-width: 768px) {
.wrapper { padding: 10px 20px 0px 20px; }
main {
width: 100%;
}
.col {
float: left;
width: 47%;
margin-left: 1.5%;
margin-right: 1.5%;
display: inline-block;
text-align: center;
vertical-align: top;
}
.col h3 {
font-size: 1.5rem;
}
drag to resize
<main>
<h2 id="portfolio">Portfolio</h2>
<!-- first row -->
<div class="row-content clearfix">
<div class="col">
<img src="images/portfolio-1.png">
<h3>Marketing Page</h3>
<p>This project shows the front page of a marketing webiste meant for a specific business I'm interested in.</p>
</div>
<div class="col">
<img src="images/portfolio-2.png">
<h3>Search Page</h3>
<p>This project searches through a specific database to find information that the user is trying to lookup.</p>
</div>
<div class="col">
<img src="images/portfolio-3.png">
<h3>Travel App</h3>
<p>This project compares travel times based on different transportation methods and tells you the best.</p>
</div>
<!-- second row -->
<div class="col">
<img src="images/portfolio-4.png">
<h3>Map of Favorite Sports</h3>
<p>This project uses mapping apps to plot points for my favorite spots in the city for a do-it-yourself walking tour.</p>
</div>
<div class="col">
<img src="images/portfolio-5.png">
<h3>Photo Gallery</h3>
<p>This project shows pictures from a recent trip to the viewer and allos them to easily navigate through photos.</p>
</div>
<div class="col">
<img src="images/portfolio-6.png">
<h3>Calculator</h3>
<p>Somone can enter in the numbers they want and press the big blue button and get the result.</p>
</div>
</div>
</main>
drag to resize
Your problem is that one of the divs is higher than the other, then, the float logic will place the third div to the left of the first div.
If you'll add borders, you'll see it more clearly. Since the first div is higher than the second, the third div still a place to be float to the first div.
If you'll give them fixed height it will solve the problem.
BUT, I suggest using a different layout. Flex for example:
Add to container:
.row-content{
display: flex;
flex-wrap: wrap;
}
and for each col :
flex-grow: 1;
flex-basis: 47%;
flex-shrink: 0;
main {
margin: 55px 0px -30px 0px;
background: linear-gradient(transparent, rgba(102, 194, 255, 0.4) 10%, transparent 99%);
padding-bottom: 5rem;
}
h2 {
text-align: center;
margin: 5rem 0;
font-size: 1.6rem;
}
h3 {
color: #353535;
font-size: 1.3rem;
margin: 1.2rem 0;
}
.row-content{
display: flex;
flex-wrap: wrap;
}
.col {
flex-grow: 1;
flex-basis: 47%;
flex-shrink: 0;
text-align: center;
margin-bottom: 15px;
}
.col p {
width: 90%;
margin: 0 auto;
}
.col img {
width: 95%;
}
/*====== 768px ==== */
#media (min-width: 768px) {
.wrapper { padding: 10px 20px 0px 20px; }
main {
width: 100%;
}
.col {
float: left;
width: 47%;
margin-left: 1.5%;
margin-right: 1.5%;
display: inline-block;
text-align: center;
vertical-align: top;
}
.col h3 {
font-size: 1.5rem;
}
drag to resize
<main>
<h2 id="portfolio">Portfolio</h2>
<!-- first row -->
<div class="row-content clearfix">
<div class="col">
<img src="images/portfolio-1.png">
<h3>Marketing Page</h3>
<p>This project shows the front page of a marketing webiste meant for a specific business I'm interested in.</p>
</div>
<div class="col">
<img src="images/portfolio-2.png">
<h3>Search Page</h3>
<p>This project searches through a specific database to find information that the user is trying to lookup.</p>
</div>
<div class="col">
<img src="images/portfolio-3.png">
<h3>Travel App</h3>
<p>This project compares travel times based on different transportation methods and tells you the best.</p>
</div>
<!-- second row -->
<div class="col">
<img src="images/portfolio-4.png">
<h3>Map of Favorite Sports</h3>
<p>This project uses mapping apps to plot points for my favorite spots in the city for a do-it-yourself walking tour.</p>
</div>
<div class="col">
<img src="images/portfolio-5.png">
<h3>Photo Gallery</h3>
<p>This project shows pictures from a recent trip to the viewer and allos them to easily navigate through photos.</p>
</div>
<div class="col">
<img src="images/portfolio-6.png">
<h3>Calculator</h3>
<p>Somone can enter in the numbers they want and press the big blue button and get the result.</p>
</div>
</div>
</main>
drag to resize
I couldn't repro this error between the given resolution but my best hunch is due to the difference in the text content. Try doing the same with the same text content for the description and it should be alright. If that's the case, you have to add a min-height to the inconsistent text-content.
.col p {
width: 90%;
margin: 0 auto;
min-height: 100px;
}