I've checked multiple times I swear I have the same amount of columns in every row. I've also check that every grid-are corresponds to its due position but I still get some pretty weird extra cells.
html:
<main>
<div class="calculator">
<div class="calculator-screen">0</div>
<div class="calculator-delete">C</div>
<div class="calculator-percent">%</div>
<div class="calculator-negative">+/-</div>
<div class="calculator-division">/</div>
<div class="calculator-7">7</div>
<div class="calculator-8">8</div>
<div class="calculator-9">9</div>
<div class="calculator-multiply">*</div>
<div class="calculator-4">4</div>
<div class="calculator-5">5</div>
<div class="calculator-6">6</div>
<div class="calculator-subtract">-</div>
<div class="calculator-1">1</div>
<div class="calculator-2">2</div>
<div class="calculator-3">3</div>
<div class="calculator-add">+</div>
<div class="calculator-dot">.</div>
<div class="calculator-zero">0</div>
<div class="calculator-squareRoot">√</div>
<div class="calculator-equals">=</div>
</div>
</main>
here's the scss:
*{
box-sizing: border-box;
padding: 0;
margin: 0;
}
html{
font-size: 62.5%;
}
body{
font-family: 'Roboto';
font-size: 1.6rem;
}
main{
width: 100vw;
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
}
.calculator{
width: 50%;
min-height: 75%;
display: grid;
grid-template-areas:
"screen screen screen screeen"
"delete percent negative division"
"7 8 9 multiply"
"4 5 6 subtract"
"1 2 3 add"
"dot zero squareRoot equals";
text-align: center;
outline: 1.5px solid black;
& > *{
outline: 1.5px solid black;
display: flex;
align-items: center;
justify-content: center;
font-size: 2.4rem;
}
&-screen{
grid-area: screen;
justify-content: end;
align-items: flex-end;
padding: 0px 20px 20px 0px;
font-size: 3rem;
}
&-delete{
grid-area: delete;
}
&-percent{
grid-area: percent;
}
&-negative{
grid-area: negative;
}
&-division{
grid-area: division;
}
&-7{
grid-area: 7;
}
&-8{
grid-area: 8;
}
&-9{
grid-area: 9;
}
&-multiply{
grid-area: multiply;
}
&-4{
grid-area: 4;
}
&-5{
grid-area: 5;
}
&-6{
grid-area: 6;
}
&-subtract{
grid-area: subtract;
}
&-1{
grid-area: 1;
}
&-2{
grid-area: 2;
}
&-3{
grid-area: 3;
}
&-add{
grid-area: add;
}
&-dot{
grid-area: dot;
}
&-zero{
grid-area: zero;
}
&-squareRoot{
grid-area: squareRoot;
}
&-equals{
grid-area: equals;
}
}
Here's the unwanted result:
Where did that 5th column and the 3 rows come from? I am honestly lost here.
#JHeth solved my question. Here's the answer:
Might be because you're using numbers as grid-area names in grid-template-areas which only accept a string. Try switching 1-7 to one-seven and see if it works.
.calculator{
width: 50%;
min-height: 75%;
display: grid;
grid-template-areas:
"screen screen screen screen"
"delete percent negative division"
"seven eight nine multiply"
"four five six subtract"
"one two three add"
"dot zero squareRoot equals";
text-align: center;
outline: 1.5px solid black;
& > *{
outline: 1.5px solid black;
display: flex;
align-items: center;
justify-content: center;
font-size: 2.4rem;
}
&-screen{
grid-area: screen;
justify-content: end;
align-items: flex-end;
padding: 0px 20px 20px 0px;
font-size: 3rem;
}
&-delete{
grid-area: delete;
}
&-percent{
grid-area: percent;
}
&-negative{
grid-area: negative;
}
&-division{
grid-area: division;
}
&-7{
grid-area: seven;
}
&-8{
grid-area: eight;
}
&-9{
grid-area: nine;
}
&-multiply{
grid-area: multiply;
}
&-4{
grid-area: four;
}
&-5{
grid-area: five;
}
&-6{
grid-area: six;
}
&-subtract{
grid-area: subtract;
}
&-1{
grid-area: one;
}
&-2{
grid-area: two;
}
&-3{
grid-area: three;
}
&-add{
grid-area: add;
}
&-dot{
grid-area: dot;
}
&-zero{
grid-area: zero;
}
&-squareRoot{
grid-area: squareRoot;
}
&-equals{
grid-area: equals;
}
Wrote down the name of the numbers instead of the numbers themselves for the grid-areas
Related
I have started using Grid CSS and i am stuck in building a Layout using Grid system.
I am looking to build a layout where the column would overlap a row and take full height. I have attached a screenshot of the layout and what i have tried so far.
body {
margin: 40px;
}
.sidebar {
grid-area: sidebar;
}
.content {
grid-area: content;
}
.header {
grid-area: header;
}
.wrapper {
display: grid;
grid-gap: 10px;
grid-template-columns: 120px 120px 120px;
grid-template-areas:
"header header header"
"sidebar content content";
background-color: #fff;
color: #444;
}
.box {
background-color: #444;
color: #fff;
border-radius: 5px;
padding: 20px;
font-size: 150%;
}
.header {
background-color: #999;
}
.overlay {
background-color: red;
z-index: 10;
grid-column: content-start / content-end;
grid-row: header-start / content-end;
}
<div class="wrapper">
<div class="box header">Header</div>
<div class="box sidebar">Sidebar</div>
<div class="overlay">Content</div>
</div>
Depending on how you want to overlap the following code works, but need to be adapted:
There's a lot of other way to do this...
body {
margin: 40px;
}
.sidebar {
grid-area: sidebar;
}
.content {
grid-area: content;
}
.header {
grid-area: header;
}
.wrapper {
display: grid;
grid-gap: 10px;
grid-template-columns: 120px 120px 120px;
grid-template-rows: 30px 30px auto auto;
grid-template-areas:
"header header header"
"sidebar content content";
background-color: #fff;
color: #444;
}
.box {
background-color: #444;
color: #fff;
border-radius: 5px;
padding: 20px;
font-size: 150%;
}
.header {
background-color: #999;
grid-row: 1 / 3;
}
.sidebar {
background-color: red;
z-index: 10;
grid-row: 2 / 4;
height: 300px;
}
.overlay {
background-color: red;
z-index: 10;
grid-column: content-start / content-end;
grid-row: 3 / 4;
}
<div class="wrapper">
<div class="box header">Header</div>
<div class="box sidebar">Sidebar</div>
<div class="overlay">Content</div>
</div>
I'm wanting to stretch out the grid to look like the second image attached in the imgur below (sorry I can't post directly on I don't have enough points to post the image directly)
My code:
.container {
display: grid;
grid-template-columns: 0.5fr 2.4fr 1.3fr 1fr;
grid-template-rows: 1fr 1fr 1fr [F] 1fr;
/* gap: 1px 0px; */
grid-auto-flow: row;
grid-template-areas:
"One oneTitle oneDescrip Picture"
"Two twoTitle twoDescrip Picture"
"Three threeTitle threeDescrip Picture"
"Four fourTitle fourDescrip Picture";
}
.One { grid-area: One; }
.Two { grid-area: Two; }
.Three { grid-area: Three; }
.Four { grid-area: Four; }
.oneTitle { grid-area: oneTitle; }
.twoTitle { grid-area: twoTitle; }
.threeTitle { grid-area: threeTitle; }
.fourTitle { grid-area: fourTitle; }
.oneDescrip { grid-area: oneDescrip; }
.twoDescrip { grid-area: twoDescrip; }
.threeDescrip { grid-area: threeDescrip; }
.fourDescrip { grid-area: fourDescrip; }
.Picture { grid-area: Picture; }
.One,.Two,.Three,.Four {
font-size: 60px;
color: lightgray;
}
.oneTitle, .twoTitle, .threeTitle, .fourTitle, .oneDescrip, .twoDescrip, .threeDescrip, .fourDescrip {
/* padding-top: 35px; */
color: black;
padding-right: 30px;
padding-left: 20px;
}
.oneTitle, .twoTitle, .threeTitle, .fourTitle {
font-weight: bold;
padding-top: 17px;
font-size: 25px;
}
<div class="container">
<div class="One">1</div>
<hr>
<div class="Two">2</div>
<div class="Three">3</div>
<div class="Four">4</div>
<div class="oneTitle">Connect your Crowds</div>
<div class="twoTitle">Gamify the Experience</div>
<div class="threeTitle">Engage with Business Growth</div>
<div class="fourTitle">Continuous Interaction</div>
<div class="oneDescrip">Descript</div>
<div class="twoDescrip">Descript</div>
<div class="threeDescrip">whehwehahha</div>
<div class="fourDescrip">Descriptjwsenwejwje</div>
<div class="Picture"><img id="block3img" src="https://i.imgur.com/PEbCBjt.png")></div>
</div>
What it looks like:
What I want it to look like:
In the .container rule set make this declaration. width: 100%;
I'm new to css and I have a specific question about overlaying using css grid.
What I am trying to achieve is having 5 circles overlaying each other. These five circles comprise two boxes on each side of a fifth circle made out of two semi-circles. I want each circle(Or semicircle) to be a different colour/object.
I want it to be responsive, so I have used a grid system.
This has caused less problems then when I attempted to resolve the problem using flex, but it still doesn't work as I need.
Here is the image of what I want to create:
Currently, the circles in the left box work perfectly, but in the right box the first element (black semi-circle) doesn't start in the left side of the box and I don't know why.
I had to use the margin property to "stick" it to the left side of the box. But then it doesn't work as responsively as I want and as it works in the left box.
Can anyone tell me please where is the problem?
Thank you
EDIT
I should have been clearer.
All elements in the right (white) box aren't working properly. Beside the problem with black semi-circle, the green circles are overflowing the parent div, when screen size is smaller.
I'm trying to figure out, why these elements don't behave same as the elements in the left box. And how to fix it.
Here is the code (without using the margin property):
html {
font-family: 'Titillium Web', sans-serif;
font-size: 20px;
}
:root {
--yellowgreen: #ECF22E;
--applegreen: #BCDD15;
--brightgreen: #f4ff96;
}
/*||Circles -----------------------------*/
.container {
display: flex;
}
.circle {
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
flex-wrap: wrap;
border-radius: 50%;
}
.circle p {
margin: 0;
}
.circle span {
font-size: 1rem;
font-weight: normal;
}
.semi-circle {
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
align-items: center;
justify-content: center;
}
.semi-circle p {
margin: 0;
}
.semi-circle span {
font-size: 1rem;
font-weight: normal;
}
#dark-box {
display: grid;
grid-template: repeat(4, 1fr) / repeat(5, 1fr);
width: 40rem;
border-top: 2px solid var(--applegreen);
border-bottom: 2px solid var(--applegreen);
background-color: black;
}
#bright-box {
display: grid;
grid-template: repeat(4, 1fr) / repeat(5, 1fr);
width: 40rem;
border-top: 2px solid var(--applegreen);
border-bottom: 2px solid var(--applegreen);
background-color: white;
}
.section-introduction .circle {
text-align: center;
height: 16rem;
width: 16rem;
font-size: 1.3rem;
font-weight: 700;
text-transform: capitalize;
}
.brightgreen-circle {
grid-row: 2 / span 2;
grid-column: 1 / span 2;
background-color: var(--brightgreen);
}
.yellowgreen-circle {
grid-row: 2 / span 2;
grid-column: 3 / span 2;
background-color: var(--yellowgreen);
}
.left-semi-circle {
border-radius: 16rem 0 0 16rem;
height: 16rem;
width: 8rem;
grid-row: 2 / span 2;
grid-column: 5 / span 1;
background-color: white;
font-size: 1.3rem;
font-weight: 700;
text-align: center;
}
.right-semi-circle {
border-radius: 0 16rem 16rem 0;
height: 16rem;
width: 8rem;
color: white;
grid-row: 2 / 4;
grid-column: 1 / span 2;
z-index: 10;
background-color: black;
font-size: 1.3rem;
font-weight: 700;
text-align: center;
}
.applegreen-circle {
grid-row: 2 / 4;
grid-column: 2 / span 2;
z-index: 2;
background-color: var(--applegreen);
}
.brightgreen-circle2 {
grid-row: 2 / 4;
grid-column: 4 / span 2;
background-color: var(--brightgreen);
}
<section class="section-introduction">
<h2 class="section-heading">Color pallete</h2>
<div class="container">
<div id="dark-box">
<div class="brightgreen-circle circle ">
<p>brightgreen</p>
<span>#F4FF96</span>
</div>
<div class="yellowgreen-circle circle">
<p>yellowgreen</p>
<span>#ECF22E</span>
</div>
<div class="left-semi-circle semi-circle">
<p>White</p>
<span>#FFFFFF</span>
</div>
</div>
<div id="bright-box">
<div class="right-semi-circle semi-circle">
<p>Black</p>
<span>#000000</span>
</p>
</div>
<div class="applegreen-circle circle">
<p>applegreen</p>
<span>#BCDD15</span>
</div>
<div class="brightgreen-circle2 circle">
<p>brightgreen</p>
<span>#F4FF96</span>
</div>
</div>
</div>
</div>
</section>
you can use a gradient for the background and a single container where you can set within your circle.
If you use 4 columns for each circle, the forth can be used for the overlapping. If that is too much, try use 5 or 6 columns.
here is the example of the idea:
html {
font-family: "Titillium Web", sans-serif;
font-size: clamp(10px, 1.5vw, 30px);
}
:root {
--yellowgreen: #ecf22e;
--applegreen: #bcdd15;
--brightgreen: #f4ff96;
}
/*||Circles -----------------------------*/
.container {
display:grid;
align-items:center;
height:30rem;
width:max-content;
margin:auto;
background:linear-gradient(to right,black 50%, white 50%);
border-top: 2px solid var(--applegreen);
border-bottom: 2px solid var(--applegreen);
}
.brightgreen-circle {
grid-row:1;
grid-column: 1 / span 4;
}
.yellowgreen-circle {
grid-row: 1;
grid-column: 4 / span 4;
}
.left-semi-circle {
grid-row: 1;
grid-column: 7 / span 2;
}
.right-semi-circle {
grid-row: 1;
grid-column: 9 / span 2;
z-index: 10;
}
.applegreen-circle {
grid-row:1;
grid-column: 10 / span 4;
}
.brightgreen-circle2 {
grid-row: 1;
grid-column: 13 / span 4;
}
.circle {
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
flex-wrap: wrap;
border-radius: 50%;
}
.circle p {
margin: 0;
}
.circle span {
font-size: 1rem;
font-weight: normal;
}
.semi-circle {
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
align-items: center;
justify-content: center;
}
.semi-circle p {
margin: 0;
}
.semi-circle span {
font-size: 1rem;
font-weight: normal;
}
.section-introduction .circle {
text-align: center;
height: 16rem;
width: 16rem;
font-size: 1.3rem;
font-weight: 700;
text-transform: capitalize;
}
.brightgreen-circle {
background-color: var(--brightgreen);
}
.yellowgreen-circle {
background-color: var(--yellowgreen);
}
.left-semi-circle {
border-radius: 16rem 0 0 16rem;
height: 16rem;
width: 8rem;
background-color: white;
font-size: 1.3rem;
font-weight: 700;
text-align: center;
}
.right-semi-circle {
border-radius: 0 16rem 16rem 0;
height: 16rem;
width: 8rem;
color: white;
z-index: 10;
background-color: black;
font-size: 1.3rem;
font-weight: 700;
text-align: center;
}
.applegreen-circle {
z-index: 2;
background-color: var(--applegreen);
}
.brightgreen-circle2 {
background-color: var(--brightgreen);
}
<section class="section-introduction">
<h2 class="section-heading">Color pallete</h2>
<div class="container">
<div class="brightgreen-circle circle ">
<p>brightgreen</p><span>#F4FF96</span>
</div>
<div class="yellowgreen-circle circle">
<p>yellowgreen</p><span>#ECF22E</span>
</div>
<div class="left-semi-circle semi-circle">
<p>White</p><span>#FFFFFF</span>
</div>
<div class="right-semi-circle semi-circle">
<p>Black</p><span>#000000</span></p>
</div>
<div class="applegreen-circle circle">
<p>applegreen</p><span>#BCDD15</span>
</div>
<div class="brightgreen-circle2 circle">
<p>brightgreen</p><span>#F4FF96</span>
</div>
</section>
note the demo sets font-size with font-size: clamp(10px, 1.5vw, 30px); so you can see it rescale if open the snippet in fullpage.
I've got some problems when I'am trying to make my section with Grid layout. Where exactly I make mistake? Can someone explaine me, please?
HTML
<body>
<header>
<div class="grid-wrapper">
<div class="item1"><span>Item 1</span></div>
<div class="item2"><span>Item 2</span></div>
<div class="item3"><span>Item 3</span></div>
<div class="item4"><span>Item 4</span></div>
<div class="item5"><span>Item 5</span></div>
</div>
</header>
</body>
CSS
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
background-color: #969d9f;
}
header {
width: 100%;
height: 100vh;
display: flex;
justify-content: center;
background-color: #969d9f;
}
.grid-wrapper {
border: 1px solid red;
width: 1200px;
display: grid;
grid-gap: 20px;
grid-template-columns: repeat(2, 1fr);
}
.item1, .item2, .item3, .item4, .item5 {
border: 1px solid grey;
background-color: #636564;
height: 360px;
display: flex;
align-items: center;
justify-content: center;
color: #fff;
font-size: 40px;
}
.item1 { width: 750px; }
.item2 { width: 360px; }
.item3 { width: 555px; }
.item4 { width: 555px; }
.item5 { width: 1200px; }
So the main question is how can I correctly display my blocks and where is my main mistake that I make?
Here is some pics:
Thank you for your attention!
its my opinion
HTML
<body>
<header>
<div class="grid-wrapper">
<div class="item1"><span>Item 1</span></div>
<div class="item2"><span>Item 2</span></div>
<div class="item3"><span>Item 3</span></div>
<div class="item4"><span>Item 4</span></div>
<div class="item5"><span>Item 5</span></div>
</div>
</header>
</body>
CSS
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
background-color: #969d9f;
}
header {
width: 100%;
height: 100vh;
display: flex;
justify-content: center;
background-color: #969d9f;
}
.grid-wrapper {
border: 1px solid red;
width: 1200px;
display: grid;
grid-gap: 20px;
grid-template-areas: "item1 item1 item2" /* make grid area */
"item3 item4 item4"
"item5 item5 item5";
grid-template-columns:(1fr, 1fr, 1fr); /* set width of colums */
}
.item1, .item2, .item3, .item4, .item5 {
border: 1px solid grey;
background-color: #636564;
height: 360px;
display: flex;
align-items: center;
justify-content: center;
color: #fff;
font-size: 40px;
}
.item1 {grid-area: item1} /* connect items with grid area */
.item2 {grid-area: item2}
.item3 {grid-area: item3}
.item4 {grid-area: item4}
.item5 {grid-area: item5}
Your layout isn't a "normal" grid (your rows 1 & 2 have cells with different widths from each other), so to resolve it, a solution could be to create more columns (3/4/5 columns: it depends by cells width and if the biggests [1&4] are equals or not) and play, for example, with grid-template-areas to create items that can... "fill more than 1 cell": in background there is a grid, but with this "trick" you can transform it as your layout.
This is a useful guide for more informations about CSS grid: https://css-tricks.com/snippets/css/complete-guide-grid/
Another solution is to use flexbox also for those rows :-)
Try it:
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
background-color: #969d9f;
}
header {
width: 100%;
/*height: 100vh;*/
display: flex;
justify-content: center;
background-color: #969d9f;
}
.grid-wrapper {
border: 1px solid red;
width: 100%;
max-width:1200px;
display: grid;
grid-gap: 20px;
grid-template-columns: repeat(4, 1fr);
grid-template-areas:
"item1 item1 item1 item2"
"item3 item4 item4 item4"
"item5 item5 item5 item5";
}
.item1, .item2, .item3, .item4, .item5 {
border: 1px solid grey;
background-color: #636564;
height: 360px;
display: flex;
align-items: center;
justify-content: center;
color: #fff;
font-size: 40px;
}
/*.item1 { width: 750px; }
.item2 { width: 360px; }
.item3 { width: 555px; }
.item4 { width: 555px; }
.item5 { width: 1200px; }*/
.item1 {
grid-area: item1;
}
.item2 {
grid-area: item2;
}
.item3 {
grid-area: item3;
}
.item4 {
grid-area: item4;
}
.item5 {
grid-area: item5;
}
<header>
<div class="grid-wrapper">
<div class="item1"><span>Item 1</span></div>
<div class="item2"><span>Item 2</span></div>
<div class="item3"><span>Item 3</span></div>
<div class="item4"><span>Item 4</span></div>
<div class="item5"><span>Item 5</span></div>
</div>
</header>
P.S. Maybe it is better don't use a fixed widths in a world of mobile device, so I changed your witdh:1200px with a max-width:1200px, but well you can change it
if you do not care about it ;-)
Here is the code. I think it's a silly error, but I can't see it -grr. I've tried many times.
The media query grid-template-areas in my code is
". title title ."
". img-1-title img-2-title ."
". img-1 img-2 ."
". img-3-title img-4-title ."
". img-3 img-4 ."
but it shows this template in my browser
"img-1 title title img-2"
"img-3 img-1-title img-2-title img-4"
". img-3-title img-4-title ."
html
<section>
<div class="grid">
<div class="title">Here is a couple of side projects</div>
<div class="img-1-title">A chat app build with socket.io and node.js</div>
<div class="arrow-1"><i class="fas fa-arrow-down"></i></div>
<div class="img-1"></div>
<div class="img-2-title">A responsive mock template of a company build with html css and flexboxgrid</div>
<div class="arrow-2"><i class="fas fa-arrow-down"></i></div>
<div class="img-2"></div>
<div class="img-3-title">Wikipedia search bar connected to the wikipedia API</div>
<div class="arrow-3"><i class="fas fa-arrow-down"></i></div>
<div class="img-3"></div>
<div class="img-4-title">Vanilla js calculator</div>
<div class="arrow-4"><i class="fas fa-arrow-down"></i></div>
<div class="img-4"></div>
</div>
</section>
The reason I redeclare my grid-area is because there is a yellow error in my console if I dont. It works, but I don't like the error, so yea.
css
.grid {
display: grid;
grid-template-columns: 1fr;
grid-template-areas:
"title"
"img-1-title"
"arrow-1"
"img-1"
"img-2-title"
"arrow-2"
"img-2"
"img-3-title"
"arrow-3"
"img-3"
"img-4-title"
"arrow-4"
"img-4";
background: rgb(27, 27, 27);
}
.title {
grid-area: title;
padding: 20px 0;
font-family: Verdana, Tahoma, sans-serif;
display: flex;
justify-content: center;
align-items: center;
font-weight: 900;
color: white;
}
.img-1 {
grid-area: img-1;
background: url("../postimg/chat_app.png") center/cover;
height: 300px;
}
.img-2 {
grid-area: img-2;
background: url("../postimg/Web_template.png") center/cover;
height: 300px;
}
.img-3 {
grid-area: img-3;
background: url("../postimg/Wiki_viewer.png") center/cover;
height: 300px;
}
.img-4 {
grid-area: img-4;
background: url("../postimg/js_calculator.png") center/cover;
height: 300px;
}
.img-1-title {
grid-area: img-1-title;
}
.img-2-title {
grid-area: img-2-title;
}
.img-3-title {
grid-area: img-3-title;
}
.img-4-title {
grid-area: img-4-title;
}
.img-1-title, .img-2-title, .img-3-title, .img-4-title {
display: flex;
height: 80px;
padding: 8px;
justify-content: center;
align-items: center;
font-weight: 200;
font-family: Verdana, Tahoma, sans-serif;
font-style: italic;
color: white;
border-top: 3px solid rgb(15, 177, 15);
}
.arrow-1 {
grid-area: arrow-1;
}
.arrow-2 {
grid-area: arrow-2;
}
.arrow-3 {
grid-area: arrow-3;
}
.arrow-4 {
grid-area: arrow-4;
}
.arrow-1, .arrow-2, .arrow-3, .arrow-4 {
display: flex;
padding: 15px;
height: 25px;
justify-content: center;
font-size: 20px;
}
.fas {
color: white;
}
#media only screen and (min-width: 1000px) {
.grid {
grid-template-columns: 200px 1fr 1fr 200px;
grid-template-areas:
". title title ."
". img-1-title img-2-title ."
". img-1 img-2 ."
". img-3-title img-4-title ."
". img-3 img-4 .";
background: rgb(27, 27, 27);
}
.title {
grid-area: title;
}
.img-1 {
grid-area: img-1;
}
.img-2 {
grid-area: img-2;
}
.img-3 {
grid-area: img-3;
}
.img-4 {
grid-area: img-4;
}
.img-1-title {
grid-area: img-1-title;
}
.img-2-title {
grid-area: img-2-title;
}
.img-3-title {
grid-area: img-3-title;
}
.img-4-title {
grid-area: img-4-title;
}
div.arrow-1, div.arrow-2, div.arrow-3, div.arrow-4 {
display: none;
}
}
Maybe it is just me but everything seems fine to me.
It is changing the media query at 1000px.
The only thing I would change is to use a grid-gap in order for the images to not clump together. This will improve the look on smaller devices by a lot.
.grid {
grid-gap: 20px;
display: grid;
grid-template-columns: 1fr;
grid-template-areas: "title" "img-1-title" "arrow-1" "img-1" "img-2-title" "arrow-2" "img-2" "img-3-title" "arrow-3" "img-3" "img-4-title" "arrow-4" "img-4";
background: rgb(27, 27, 27);
}
.title {
grid-area: title;
padding: 20px 0;
font-family: Verdana, Tahoma, sans-serif;
display: flex;
justify-content: center;
align-items: center;
font-weight: 900;
color: white;
}
.img-1 {
grid-area: img-1;
background: url("http://placekitten.com/1500/650") center/cover;
height: 300px;
}
.img-2 {
grid-area: img-2;
background: url("http://placekitten.com/1500/500") center/cover;
height: 300px;
}
.img-3 {
grid-area: img-3;
background: url("http://placekitten.com/2500/500") center/cover;
height: 300px;
}
.img-4 {
grid-area: img-4;
background: url("http://placekitten.com/1500/600") center/cover;
height: 300px;
}
.img-1-title {
grid-area: img-1-title;
}
.img-2-title {
grid-area: img-2-title;
}
.img-3-title {
grid-area: img-3-title;
}
.img-4-title {
grid-area: img-4-title;
}
.img-1-title,
.img-2-title,
.img-3-title,
.img-4-title {
display: flex;
height: 80px;
padding: 8px;
justify-content: center;
align-items: center;
font-weight: 200;
font-family: Verdana, Tahoma, sans-serif;
font-style: italic;
color: white;
border-top: 3px solid rgb(15, 177, 15);
}
.arrow-1 {
grid-area: arrow-1;
}
.arrow-2 {
grid-area: arrow-2;
}
.arrow-3 {
grid-area: arrow-3;
}
.arrow-4 {
grid-area: arrow-4;
}
.arrow-1,
.arrow-2,
.arrow-3,
.arrow-4 {
display: flex;
padding: 15px;
height: 25px;
justify-content: center;
font-size: 20px;
}
.fas {
color: white;
}
#media only screen and (min-width: 1000px) {
.grid {
grid-template-columns: 200px 1fr 1fr 200px;
grid-template-areas: ". title title ." ". img-1-title img-2-title ." ". img-1 img-2 ." ". img-3-title img-4-title ." ". img-3 img-4 .";
background: rgb(27, 27, 27);
}
.title {
grid-area: title;
}
.img-1 {
grid-area: img-1;
}
.img-2 {
grid-area: img-2;
}
.img-3 {
grid-area: img-3;
}
.img-4 {
grid-area: img-4;
}
.img-1-title {
grid-area: img-1-title;
}
.img-2-title {
grid-area: img-2-title;
}
.img-3-title {
grid-area: img-3-title;
}
.img-4-title {
grid-area: img-4-title;
}
div.arrow-1,
div.arrow-2,
div.arrow-3,
div.arrow-4 {
display: none;
}
}
<section>
<div class="grid">
<div class="title">Here is a couple of side projects</div>
<div class="img-1-title">A chat app build with socket.io and node.js</div>
<div class="arrow-1"><i class="fas fa-arrow-down"></i></div>
<div class="img-1"></div>
<div class="img-2-title">A responsive mock template of a company build with html css and flexboxgrid</div>
<div class="arrow-2"><i class="fas fa-arrow-down"></i></div>
<div class="img-2"></div>
<div class="img-3-title">Wikipedia search bar connected to the wikipedia API</div>
<div class="arrow-3"><i class="fas fa-arrow-down"></i></div>
<div class="img-3"></div>
<div class="img-4-title">Vanilla js calculator</div>
<div class="arrow-4"><i class="fas fa-arrow-down"></i></div>
<div class="img-4"></div>
</div>
</section>
I am sry if I misunderstood your question :D
The problem might be your browser since you already had problems there.
The reason I redeclare my grid-area is because there is a yellow error in my console if I dont. It works, but I don't like the error, so yea.
Firefox seems to work fine so you could try to use it. They also have this nice grid-view which shows you the css grid.
For reference my version of firefox is Firefox Quantum 61.0.1 (64-Bit)
Since you are using Chrome I also looked at the problem in Chrome and the files also worked fine on my Chrome version Version 68.0.3440.75 (official build) (64-Bit)
You should probably check your version of chrome and compare it with the list of supported browser.
If you don't know how to check your browser version here is a small guide for most modern web browser. [LINK]
OMG, I found my problem, I had <a> tags before my divs that was messing up the grid, I don't know why I didn't include them in my HTML, I presumed it wasn't the problem, - smacks forehead.