How can I make this design from Figma in HTML/CSS? - html

Ia m trying to make this card design from Figma and code it in HTMl/CSS but I am having a bit of issues.
h
Here is an image of the design itself
And here is what I have currently made looks like: (note: I had to zoom out of page because it wouldn't be visible otherwise)
Here is the HTML code for it:
<div class="cards-container">
<div class="box1_1">
<div class="box1_3">
<p>CAREY</p>
<h1>1</h1>
</div>
<div class="box1_2">
<p>On 56 Points</p>
</div>
</div>
<div class="box1_1">
<div class="box1_3">
<p>CAREY</p>
<h1>1</h1>
</div>
<div class="box1_2">
<p>On 56 Points</p>
</div>
</div>
<div class="right-cards-container">
<div class="box1_1">
<div class="box1_3">
<p>CAREY</p>
<h1>1</h1>
</div>
<div class="box1_2">
<p>On 56 Points</p>
</div>
</div>
<div class="box1_1">
<div class="box1_3">
<p>CAREY</p>
<h1>1</h1>
</div>
<div class="box1_2">
<p>On 56 Points</p>
</div>
</div>
</div>
</div>
And here is the CSS code for it:
.box1_1 {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
width: 262px;
height: 276px;
background: gray;
opacity: 1;
border-radius: 44px;
box-shadow: -10.746728897094727px 9.851167678833008px 60px rgba(0, 0, 0, 0.09000000357627869);
overflow: hidden;
position: relative;
}
.box1_3 {
padding-top: 20%;
font-size: 25px;
font-weight: bold;
text-align: center;
background: white;
height: 100%;
width: 100%;
position: absolute;
top: 10;
}
.box1_2 {
font-size: 25px;
font-weight: bold;
text-align: center;
background: #f6df6f;
height: 35%;
width: 100%;
position: absolute;
bottom: 0%;
box-shadow: -10.746728897094727px 9.851167678833008px 60px rgba(0, 0, 0, 0.09000000357627869);
/* Add the same box-shadow as the parent container */
}
.box1_3 h1 {
font-size: 72px;
margin-top: -10px;
}
.box1_2 p {
font-size: 18px;
}
.cards-container {
display: flex;
align-items: center;
flex-direction: column;
gap: 50px;
margin-top: 50px;
}
.right-cards-container {
display: flex;
flex-direction: row;
gap: 50px;
align-items: flex-end;
align-self: flex-end;
}
.right-cards-container .box1_1 {
width: 205px;
height: 215px;
}
I would appreciate it if someone can help me please.
Thanks.
I tried to a main container for all the cards and a seperate container for right cards and left cards. But I don't know how to format it properly to be responsive too.

If i were you i would use bootstrap (or another css framework) but if you need to use plan html/css then you could do something like this:
.box1_1 {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
width: 262px;
height: 276px;
background: gray;
opacity: 1;
border-radius: 44px;
box-shadow: -10.746728897094727px 9.851167678833008px 60px rgba(0, 0, 0, 0.09000000357627869);
overflow: hidden;
position: relative;
}
.box1_3 {
padding-top: 20%;
font-size: 25px;
font-weight: bold;
text-align: center;
background: white;
height: 100%;
width: 100%;
position: absolute;
top: 10;
}
.box1_2 {
font-size: 25px;
font-weight: bold;
text-align: center;
background: #f6df6f;
height: 35%;
width: 100%;
position: absolute;
bottom: 0%;
box-shadow: -10.746728897094727px 9.851167678833008px 60px rgba(0, 0, 0, 0.09000000357627869);
/* Add the same box-shadow as the parent container */
}
.box1_3 h1 {
font-size: 72px;
margin-top: -10px;
}
.box1_2 p {
font-size: 18px;
}
.cards-container {
display: flex;
align-items: center;
flex-direction: column;
gap: 50px;
margin-top: 50px;
}
.right-cards-container {
display: flex;
flex-direction: row;
gap: 50px;
align-items: flex-end;
align-self: flex-end;
}
.right-cards-container .box1_1 {
width: 205px;
height: 215px;
}
<table class="cards-container">
<tr>
<th>
<div class="box1_1">
<div class="box1_3">
<p>CAREY</p>
<h1>1</h1>
</div>
<div class="box1_2">
<p>On 56 Points</p>
</div>
</div>
<div class="box1_1">
<div class="box1_3">
<p>CAREY</p>
<h1>1</h1>
</div>
<div class="box1_2">
<p>On 56 Points</p>
</div>
</div>
</th>
<th>
<div class="box1_1">
<div class="box1_3">
<p>CAREY</p>
<h1>1</h1>
</div>
<div class="box1_2">
<p>On 56 Points</p>
</div>
</div>
</th>
<th>
<div class="box1_1">
<div class="box1_3">
<p>CAREY</p>
<h1>1</h1>
</div>
<div class="box1_2">
<p>On 56 Points</p>
</div>
</div>
</th>
</tr>
<
Edit: Here is how i would do it using bootstrap
*{
padding:0;
margin:0;
}
.box{
height:200px;
width: 200px;
border-radius: 40px;
justify-items: center;
box-shadow: 0px 0px 20px #b8b8b842;
}
.box_header{
height: 60%;
text-align: center;
}
.box_description{
text-align: center;
height: 40%;
width: 100%;
background-color: #f6df6f;
border-bottom-left-radius: 40px;
border-bottom-right-radius: 40px;
}
<!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">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<link rel="stylesheet" href="styles.css">
<title>Document</title>
</head>
<body class="container-fluid">
<div class="row">
<div class="col-sm-4">
<div class="box">
<div class="box_header">
<p>CAREY</p>
<h1>1</h1>
</div>
<div class="box_description">
<p>On 56 Points</p>
</div>
</div>
<div class="box">
<div class="box_header">
<p>CAREY</p>
<h1>1</h1>
</div>
<div class="box_description">
<p>On 56 Points</p>
</div>
</div>
</div>
<div class="col-sm-4">
<div class="box" >
<div class="box_header">
<p>CAREY</p>
<h1>1</h1>
</div>
<div class="box_description">
<p>On 56 Points</p>
</div>
</div>
</div>
<div class="col-sm-4">
<div class="box" >
<div class="box_header">
<p>CAREY</p>
<h1>1</h1>
</div>
<div class="box_description">
<p>On 56 Points</p>
</div>
</div>
</div>
</div>
</body>
</html>

CSS Grid can do this quite easily.
In reality, the layout is accomplished in just a few lines of code in the media query in the example below. For all screens up to 50em, the .grid container is set to just auto-flow its children in a column. After the breakpoint is reached, I created a grid-template that allows you to place the first, second, third and fourth place cards into specific areas using a simple name (e.g., .first { grid-area: first; }).
* {
/* reset */
box-sizing: border-box;
font-weight: 400;
margin: 0;
}
:root {
/* default size of the cards */
--size: 15rem;
}
body {
/*
grid makes it easy to center
the entire main vertically
*/
display: grid;
/* default inheritable font values */
font-family: sans-serif;
line-height: 1;
/* make height at least the size of the viewport*/
min-height: 100vh;
}
.grid {
/* the main grid */
display: grid;
gap: 2rem;
/* all children flow into a column by default */
grid-auto-flow: columns;
justify-items: center;
/*
center the grid on the page horizontally
give the grid top and bottom margin of 2rem
*/
margin: 2rem auto;
}
.card {
/* card base styles */
aspect-ratio: 1;
align-self: center;
background-color: white;
border-radius: 20%;
box-shadow: 0 0 2rem hsl(0 0% 0% / .25);
display: grid;
grid-template-rows: 2fr 4fr 3fr;
height: var(--size);
overflow: hidden;
text-align: center;
}
.card h2 {
align-self: end;
font-size: 1.5rem;
text-transform: uppercase;
}
.card h3 {
align-self: center;
font-size: 5rem;
font-weight: 700;
}
.card h4 {
align-self: center;
font-size: 1.25rem;
}
.card p {
align-self: center;
font-size: .95rem;
margin-top: .75rem;
}
.card footer {
padding: 1rem 1rem .5rem;
background-color: var(--color);
}
/* give each card its own background-color */
.first {
--color: yellow;
}
.second {
--color: lime;
}
.third {
--color: dodgerblue;
}
.fourth {
--color: orangered;
}
#media screen and (min-width: 50em) {
.grid {
/* create the named grid areas */
grid-template-areas:
"first first blank-a blank-a"
"first first third fourth"
"second second third fourth"
"second second blank-b blank-b";
width: max-content;
}
.first {
/* enlarge this card */
--size: 18rem;
/* adjust the card placement in the grid area */
justify-self: end;
align-self: end;
/* place the card in the grid area */
grid-area: first;
}
.second {
/* enlarge this card */
--size: 18rem;
/* adjust the card placement in the grid area */
justify-self: end;
align-self: start;
/* place the card in the grid area */
grid-area: second;
}
.third {
/* place the card in the grid area */
grid-area: third;
}
.fourth {
/* place the card in the grid area */
grid-area: fourth;
}
/*
update the card font-sizes for
the first and second cards
*/
.card:where(.first, .second) h2 {
font-size: 2rem;
}
.card:where(.first, .second) h3 {
font-size: 6rem;
}
.card:where(.first, .second) h4 {
font-size: 1.5rem;
}
.card:where(.first, .second) p {
font-size: 1.1rem;
}
}
<main class="grid">
<div class="card first">
<h2>Carey</h2>
<h3>1</h3>
<footer>
<h4>On 56 Points</h4>
</footer>
</div>
<div class="card second">
<h2>Stanway</h2>
<h3>2</h3>
<footer>
<h4>On 40 Points</h4>
<p>16 points behind Carey</p>
</footer>
</div>
<div class="card third">
<h2>Judson</h2>
<h3>3</h3>
<footer>
<h4>On 36 Points</h4>
<p>4 points behind Stanway</p>
</footer>
</div>
<div class="card fourth">
<h2>Taylor</h2>
<h3>4</h3>
<footer>
<h4>On 10 Points</h4>
<p>26 points behind Judson</p>
</footer>
</div>
</main>

Related

Text below images in css grid is making them change size based on length of text

I'm a bit new to front end and doing my best to figure things out. I have been building a relatively simple landing page and all looking great except when I try to use a css grid. The text (people's names) is changing the size of the images so that none of them are the same size (see the attached image). It seems that the images directly above and below each other grow together if the text is changed for one. While the images next to each other left and right change inversely. Removing all text makes them the same size.
Here is a fiddle for a runnable copy.
I would really like to set the grid to take up a percentage of the container it's in if it's possible. For the life of me I can't find what I am missing. Is there some way that I can set all images to stay the same size as one another?
I will try to include the relevant pieces of CSS.
.team {
padding: 66px 0 80px 0;
background-image: url("assets/pattern-team.png");
background-repeat: no-repeat;
background-size: contain;
background-position: center center;
width: 100%;
}
.team .container {
display: flex;
}
.team-heading {
width: 30%;
margin-right: 80px;
}
.team-heading p {
margin-top: 17px;
}
.team-members {
width: 70%;
display: grid;
grid-template-areas: "name1." "name2 name3";
gap: 30px;
row-gap: 30px;
}
.name1 {
grid-area: name1;
}
.name2 {
grid-area: name2;
}
.name3 {
grid-area: name3;
}
enter code here .team-member {
cursor: pointer;
}
.team-member .team-img {
box-shadow: 10px 10px #7CE04E;
border: 2px solid black;
}
.team-member h4 {
margin: 15px 0 5px 0;
}
.team img {
display: block;
}
<!-- Our team -->
<section class="team">
<div class="container">
<div class="team-heading">
<h2>Our team</h2>
<p>Meet the cats behind the magic.</p>
</div>
<div class="team-members">
<!-- Griff -->
<div class="team-member griff">
<div>
<img class="team-img" src="https://upload.wikimedia.org/wikipedia/commons/6/62/Solid_red.svg" />
</div>
<h4>Griff</h4>
<p>description</p>
</div>
<!-- Brenden -->
<div class="team-member brenden">
<div>
<img class="team-img" src="https://upload.wikimedia.org/wikipedia/commons/6/62/Solid_red.svg" />
</div>
<h4>Brenden</h4>
<p>description</p>
</div>
<!-- Thu -->
<div class="team-member thu">
<div>
<img class="team-img" src="https://upload.wikimedia.org/wikipedia/commons/6/62/Solid_red.svg" />
</div>
<h4>Thu</h4>
<p>description</p>
</div>
</div>
</div>
</section>
Thanks in advance for any pointers or even a suggestion of where to start searching!
Simply add column templates:
grid-template-columns: 1fr 1fr;
h4 {
font-size: 33px;
line-height: 43px;
}
.team {
padding: 66px 0 80px 0;
background-image: url("assets/pattern-team.png");
background-repeat: no-repeat;
background-size: contain;
background-position: center center;
width: 100%;
}
.team .container {
display: flex;
}
.team-heading {
width: 30%;
margin-right: 80px;
}
.team-heading p {
margin-top: 17px;
}
.team-members {
width: 70%;
display: grid;
/*Set 2 eqaul columns*/
grid-template-columns: 1fr 1fr;
grid-template-areas: "griff ." "brenden thu";
gap: 30px;
row-gap: 30px;
}
.griff {
grid-area: griff;
}
.brenden {
grid-area: brenden;
}
.thu {
grid-area: thu;
}
.team-member .team-img {
box-shadow: 10px 10px #7CE04E;
border: 2px solid black;
}
.team-member h4 {
margin: 15px 0 5px 0;
}
.team img {
display: block;
}
<!-- Our team -->
<section class="team">
<div class="container">
<div class="team-heading">
<h2>Our team</h2>
<p>Meet the cats behind the magic.</p>
</div>
<div class="team-members">
<!-- Griff -->
<div class="team-member griff">
<div>
<img
class="team-img"
src="https://upload.wikimedia.org/wikipedia/commons/6/62/Solid_red.svg"
/>
</div>
<h4>Griff</h4>
<p>description</p>
</div>
<!-- Brenden -->
<div class="team-member brenden">
<div>
<img
class="team-img"
src="https://upload.wikimedia.org/wikipedia/commons/6/62/Solid_red.svg"
/>
</div>
<h4>Brenden</h4>
<p>description</p>
</div>
<!-- Thu -->
<div class="team-member thu">
<div>
<img class="team-img" src="https://upload.wikimedia.org/wikipedia/commons/6/62/Solid_red.svg"/>
</div>
<h4>Thu</h4>
<p>description</p>
</div>
</div>
</div>
</section>

Why I can't set image on top of div in scroll wrapper div card

I created a cards-based horizontal scroller. And the cards are nicely scrolling inside the wrapper. The issue I'm having is that even after I applied the z-index to our member-owner-card-image, the photos still go under the card when I want to put them on the top of each card.
Is there any solution so that I can add the image on top of the card? I'm trying to fix it, but no solution has been found.
.scrolling-wrapper {
-webkit-overflow-scrolling: touch;
height: 331px;
width: 100%;
padding-inline: 40px;
position: relative;
display: flex;
flex-wrap: nowrap;
overflow-x: auto;
z-index: 0;
}
.scrolling-wrapper::-webkit-scrollbar {
display: none;
}
.card {
width: 100%;
flex: 0 0 auto;
background-color: green;
border-radius: 20px;
position: relative;
margin-right: 10px;
}
.our-member-owner-card-image {
position: absolute;
top: -30px;
z-index: 10;
}
.card-content {
position: absolute;
padding-top: 38px;
}
.member-detail {
padding-top: 55px;
line-height: 1.7;
}
.member-detail h3 {
text-align: center;
color: #263244;
font-weight: 700;
font-family: 'Lato';
}
.member-detail p {
text-align: center;
color: #737C89;
}
.member-description {
padding-inline: 20px;
color: #263244;
line-height: 1.6;
padding-top: 9px;
font-weight: 500;
font-size: 17px;
}
.member-description span {
color: red;
text-decoration: underline;
}
<div class="scrolling-wrapper">
<div class="card">
<div class="our-member-owner-card-image">
<img width="220px" src="https://images.unsplash.com/photo-1661961110144-12ac85918e40?ixlib=rb-4.0.3&ixid=MnwxMjA3fDF8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=870&q=80" />
</div>
<div class="card-content">
<div class="member-detail">
<h3>Sohaib</h3>
<p>Chairman</p>
</div>
<div class="member-description">
Sohaib Ashraf has extensive work experience during his career
of more than 25 years in the financial services sector.<span
>Read more</span
>
</div>
</div>
</div>
<div class="card">
<div class="our-member-owner-card-image">
<img width="220px" src="https://images.unsplash.com/photo-1661961110144-12ac85918e40?ixlib=rb-4.0.3&ixid=MnwxMjA3fDF8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=870&q=80" />
</div>
<div class="card-content">
<div class="member-detail">
<h3>Sohaib Ashraf</h3>
<p>Chairman</p>
</div>
<div class="member-description">
Sohaib Ashraf has extensive work experience during his career
of more than 25 years in the financial services sector.<span
>Read more</span
>
</div>
</div>
</div>
</div>
You could add the image as a background-image to the card. I added few examples how you can use background-image:
.card{
width: 400px;
height: 300px;
margin: 10px;
border-radius: 6px;
background-color: gray;
}
.card-1, .card-2 .image, .card-3 .image{
/* Here, we use background-image to set the image */
background-image: url("https://images.unsplash.com/photo-1661961110144-12ac85918e40?ixlib=rb-4.0.3&ixid=MnwxMjA3fDF8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=870&q=80");
/* The background should be a cover photo,
so it fills the whole card: */
background-size: cover;
/* We don't want the image to repeat itself */
background-repeat: no-repeat;
/* When the ratio of the image changes, it will zoom into
this point, which we want to happen in the center of the image */
background-position: center;
}
.card-2, .card-3{
display: grid;
grid-template-rows: 1fr 1fr;
}
.card-2 .image{
border-radius: 6px 6px 0px 0px;
}
.card-3{
padding: 10px;
}
/* This is to demonstrate: */
h2{
color: white;
display: flex;
justify-content: center;
font-family: sans-serif;
}
<div class="card-1 card">
<h2>Test title</h2>
</div>
<div class="card-2 card">
<div class="image"></div>
<div class="content">
<h2> Test title</h2>
</div>
</div>
<div class="card-3 card">
<div class="image"></div>
<div class="content">
<h2> Test title</h2>
</div>
</div>

White corners after border-radius

I want to create a card (that is an image and an overlay). The card should be with border-radius. Unfortunately, when I add it in conjunction with overflow-y: hidden, it creates some white pixels on the corners.
I have the following HTML structure and CSS code:
.container {
max-width: 80rem;
padding: 1em;
margin-inline: auto;
}
.works__column {
display: flex;
flex-direction: column;
gap: 2rem;
}
.size {
--size: 0;
width: var(--size);
height: var(--size);
}
.work {
display: grid;
overflow-y: hidden;
border-radius: .5rem;
}
.work__preview,
.work__overlay {
grid-area: 1 / 2;
}
.work__preview img {
--size: 100%;
object-fit: cover;
aspect-ratio: 2 / 1.4;
}
.work__overlay {
align-self: end;
padding-right: 1rem;
display: flex;
gap: 2rem;
justify-content: space-between;
}
.work__title {
font-weight: 600;
line-height: 1.6;
color: var(--white);
padding: .5rem 1rem;
border-start-end-radius: .5rem;
background-color: var(--steel-gray);
}
.work__icon {
flex-shrink: 0;
align-self: center;
margin-bottom: .125rem;
}
<section class="works">
<div class="container">
<div class="works__column">
<div class="works__work work">
<div class="work__preview">
<img class="size" alt="Sports Elements" src="images/works/1.jpg" />
</div>
<div class="work__overlay">
<h3 class="work__title">
Portier - The ultimate templates & components library.
</h3>
<div class="work__icon icon">0</div>
</div>
</div>
<div class="works__work work">
<div class="work__preview">
<img class="size" alt="The Coporate" src="images/works/2.jpg" />
</div>
<div class="work__overlay">
<h3 class="work__title">
The Coporate - Card for Indian Startups
</h3>
<div class="work__icon icon">1</div>
</div>
</div>
<div class="works__work work">
<div class="work__preview">
<img class="size" alt="App Interface" src="images/works/3.jpg" />
</div>
<div class="work__overlay">
<h3 class="work__title">
Components Web App Interface
</h3>
<div class="work__icon icon">2</div>
</div>
</div>
</div>
</div>
</section>
You can see the problem in these images:
However, the last card works as expected. I don't know the reason.
I think the problem is that I applied aspect-ratio with height: 100% on work__preview img. This is required because the parent has a greater hight and the overlay starts to hang from the image.

Pinning icons to top of the vertical flexbox bar

I have 3 vertical flexbox bars with different height and I'd like to place 3 different icons on the top of 3 vertical bars.
I tried by using margin and padding to fix the icons at the top of the flexbox but when i switch the window to responsive mode then again icons moves to different places.
Here is an image of how i wanted:
Here's an image of how i am getting like:
My HTML Code:
<div>
<div className="prize">
<div class="prizeimage2">
<img src={prizeTwo} alt="2ndprizeicon"/>
</div>
<div class="prizeimage1">
<img src={prizeOne} alt="1stprizeicon"/>
</div>
<div class="prizeimage3">
<img src={prizeThree} alt="3rdprizeicon"/>
</div>
</div>
<div className="container">
<div class="item item1">
<p className="hourstext">28<br></br> hrs</p>
</div>
<div class="item item2">
<p className="hourstext">25<br></br> hrs</p>
</div>
<div class="item item3">
<p className="hourstext">30<br></br> hrs</p>
</div>
</div>
</div>
CSS:
.container {
position: absolute;
width: 100%;
height: 70%;
left: 0px;
top: 0px;
display: flex;
justify-content: center;
align-items: flex-end;
background: #162983;
}
.prize{
position: relative;
display: flex;
flex-direction: row;
justify-content: space-around;
align-items: center;
z-index: 1;
}
.item {
width: 75px;
background: #8C9CE7;
}
.item1 {
height: 35%;
margin-left: 2px;
}
.item2 {
height: 45%;
margin-left: 9px;
}
.item3 {
height: 20%;
margin-left: 10px;
}
.prizeimage1 {
padding-bottom: 5%;
}
.prizeimage2 {
padding-top: 45px;
}
.prizeimage3 {
padding-top: 190px;
}

Scaling the grid in different mobile screens

I'm working on creating UI (header, grid, and buttons) and would like it to be the same on every mobile screen. These are the screenshots from different mobile screens right now:
Samsung S5
Pixel 2 XL
Ipad
I'd like the grid in Pixel 2 XL and Ipad to scale like it's scaled in Samsung S5, i.e. in those two screenshots there is a decent amount of white space after Exit button.
I'd like those buttons be on the bottom of the screen, header - on the very top, and the rest covered by the grid.
I feel like I'm doing something wrong with assigning height of the grid - if I make it higher then the buttons would be beyond in Samsung S5. Could somebody help me out with that ?
Code:
HTML:
<div className="component">
<div className="header">
<h3 className="header-title">
Let&apos;s play!
</h3>
<div>
Click the tiles!
</div>
</div>
<div className="grid">
<div className="box"><div className="inner">1</div></div>
<div className="box"><div className="inner">2</div></div>
<div className="box"><div className="inner">3</div></div>
<div className="box"><div className="inner">4</div></div>
<div className="box"><div className="inner">5</div></div>
<div className="box"><div className="inner">6</div></div>
</div>
<div className="buttonAndInput">
<div className="button">
<button
className="primary button-continue">
Start the Game
</button>
</div>
<div className="link">
<a
className="link-text">
Exit
</a>
</div>
</div>
</div>
CSS:
.component {
width: 100%;
height: 100%;
background-color: white;
text-align: center;
}
.header {
margin: 1rem 0;
height: 10%;
}
.grid {
margin: 0 auto;
width: 90%;
height: 70%;
display: flex;
flex-wrap: wrap;
}
.box {
width: 44%;
margin: 5px;
color: black;
font-weight: bold;
flex: 1 0 auto;
position: relative;
border: 1px solid #d2d2d2;
border-radius: 5px;
background: white;
cursor: pointer;
text-align: center;
}
.box .inner {
position: absolute;
left: 0;
right: 0;
bottom: 0;
top: 0;
display: flex;
align-items: center;
justify-content: center;
}
.buttonAndInput {
width: 100%;
height: 20%;
margin-top: 0.5rem;
background-color: white;
animation-fill-mode: backwards;
}
.input-text {
width: 100%;
height: 35px;
font-size: 0.833rem;
padding: 0 1rem;
border-radius: 5px;
border: 1px solid #d2d2d2;
-webkit-appearance: none;
-moz-appearance: none;
}
.button {
margin-top: 0.5rem;
&-continue {
height: 35px;
width: 250px;
padding: 0 !important;
}
}
.link {
margin-top: 0.5rem;
a {
text-align: center;
}
}
Give your .component a height: 100vh and flex each of the children (.header, .grid and .buttonAndInput)
html,
body {
margin: 0;
}
.component {
height: 100vh;
text-align: center;
display: flex;
flex-direction: column;
}
.header {
padding: 1rem 0;
flex: 1 1 10%;
}
.grid {
width: 90%;
margin: 0 auto;
flex: 1 1 70%;
display: flex;
flex-wrap: wrap;
}
.box {
flex: 1 1 50%;
position: relative;
cursor: pointer;
}
.box .inner {
border-radius: 5px;
margin: 5px;
border: 1px solid #d2d2d2;
position: absolute;
left: 0;
right: 0;
bottom: 0;
top: 0;
display: flex;
align-items: center;
justify-content: center;
}
.buttonAndInput {
width: 100%;
flex: 1 1 20%;
padding-top: 0.5rem;
}
.button {
margin-top: 0.5rem;
}
.button-continue {
height: 35px;
width: 250px;
}
.link {
margin-top: 0.5rem;
}
.link a {
text-align: center;
}
<div class="component">
<div class="header">
<h3 class="header-title">
Let&apos;s play!
</h3>
<div>
Click the tiles!
</div>
</div>
<div class="grid">
<div class="box">
<div class="inner">1</div>
</div>
<div class="box">
<div class="inner">2</div>
</div>
<div class="box">
<div class="inner">3</div>
</div>
<div class="box">
<div class="inner">4</div>
</div>
<div class="box">
<div class="inner">5</div>
</div>
<div class="box">
<div class="inner">6</div>
</div>
</div>
<div class="buttonAndInput">
<div class="button">
<button class="primary button-continue">
Start the Game
</button>
</div>
<div class="link">
<a class="link-text">
Exit
</a>
</div>
</div>
</div>