The issue of CSS Grid not adapting fully to different screen sizes and

Recently, I took on a coding challenge from Frontend Mentor (this one) and managed to complete it successfully. However, the grid I designed is not fully responsive. It only adapts correctly when the page width matches the media query specifications. The content within the grid fails to adjust as the browser window size changes, which is not ideal.

If you want to see an example of how it should function, check out this link.

body,
html {
  background-color: hsl(210, 46%, 95%);
  font-family: 'Barlow Semi Condensed', sans-serif;
  Font-size: 13px;
  display: flex;
  justify-content: center;
  align-items: center;
  box-sizing: border-box;
}

.container {
  width: 1440px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-areas: "t1 t1 t2 t3" "t4 t5 t5 t3";
  grid-gap: 2.5rem;
}

.testimonial01,
.testimonial02,
.testimonial05 {
  color: white;
}

.testimonial04,
.testimonial03 {
  color: hsl(217, 19%, 35%);
}

.container>div {
  padding: 2rem;
}

.author {
  display: flex;
  width: 180px;
  align-items: center;
}

span,
h3 {
  opacity: 50%;
  line-height: 1.6;
}

img {
  width: 3rem;
  border-radius: 50%;
  border: 1px solid white;
  margin-right: 20px;
}

.testimonial01 {
  grid-area: t1;
  background-color: hsl(263, 55%, 52%);
  border-radius: 15px;
}

.testimonial02 {
  grid-area: t2;
  background-color: hsl(217, 19%, 35%);
  border-radius: 15px;
}

.testimonial03 {
  grid-area: t3;
  background-color: hsl(0, 0%, 100%);
  border-radius: 15px;
}

.testimonial04 {
  grid-area: t4;
  background-color: hsl(0, 0%, 100%);
  border-radius: 15px;
}

.testimonial05 {
  grid-area: t5;
  background-color: hsl(219, 29%, 14%);
  border-radius: 15px;
}

@media screen and (max-width: 600px) {
  .container {
    width: 375px;
    padding: 50px;
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1fr 1fr 1fr 1fr;
    grid-template-areas: "t1" "t2" "t3" "t4" "t5";
  }
}
<!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="styles.css">
  <link rel="preconnect" href="https://fonts.googleapis.com">
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
  <link href="https://fonts.googleapis.com/css2?family=Barlow+Semi+Condensed:wght@500;600&display=swap" rel="stylesheet">
  <title>Testimonials</title>
</head>

<body>
  <div class="container">

    <div class="testimonial01">

      <div class="author">
        <img src="./images/image-daniel.jpg" alt="">
        <p>Daniel Clifford <br>
          <span> Verified Graduate</span></p>
      </div>

      <h1>I received a job offer mid-course, and the subjects I learned were current, if not more so, in the company I joined. I honestly feel I got every penny’s worth.</h1>

      <h3>" I was an EMT for many years before joining the bootcamp. I’ve been looking to make a transition and have heard some people who had an amazing experience here. I signed up for the free intro course and found it incredibly fun! I enrolled shortly
        thereafter. The next 12 weeks was the best - and most grueling - time of my life. Since completing the course, I’ve successfully switched careers, working as a Software Engineer at a VR startup. ”</h3>

    </div>

    <div class="testimonial02">

      <div class="author">
        <img src="./images/image-jonathan.jpg" alt="">
        <p>Jonathan Walters <br>
          <span> Verified Graduate</span></p>
      </div>

      <h1>The team was very supportive and kept me motivated</h1>

      <h3>“ I started as a total newbie with virtually no coding skills. I now work as a mobile engineer for a big company. This was one of the best investments I’ve made in myself. ”</h3>

    </div>

    <div class="testimonial03">

      <div class="author">
        <img src="./images/image-kira.jpg" alt="">
        <p>Kira Whittle <br>
          <span> Verified Graduate</span></p>
      </div>

      <h1>Such a life-changing experience. Highly recommended!</h1>

      <h3>“ Before joining the bootcamp, I’ve never written a line of code. I needed some structure from professionals who can help me learn programming step by step. I was encouraged to enroll by a former student of theirs who can only say wonderful things
        about the program. The entire curriculum and staff did not disappoint. They were very hands-on and I never had to wait long for assistance. The agile team project, in particular, was outstanding. It took my learning to the next level in a way
        that no tutorial could ever have. In fact, I’ve often referred to it during interviews as an example of my developent experience. It certainly helped me land a job as a full-stack developer after receiving multiple offers. 100% recommend! ”</h3>

    </div>

    <div class="testimonial04">

      <div class="author">
        <img src="./images/image-jeanette.jpg" alt="">
        <p>Jeanette Wittle <br>
          <span> Verified Graduate</span></p>
      </div>

      <h1>An overall wonderful and rewarding experience</h1>

      <h3>“ Thank you for the wonderful experience! I now have a job I really enjoy, and make a good living while doing something I love. ”</h3>

    </div>
    <div class="testimonial05">

      <div class="author">
        <img src="./images/image-patrick.jpg" alt="">
        <p>Patrick Abrams <br>
          <span> Verified Graduate</span></p>
      </div>

      <h1>Awesome teaching support from TAs who did the bootcamp themselves. Getting guidance from them and learning from their experiences was easy.</h1>

      <h3>“ The staff seem genuinely concerned about my progress which I find really refreshing. The program gave me the confidence necessary to be able to go out in the world and present myself as a capable junior developer. The standard is above the rest.
        You will get the personal attention you need from an incredible community of smart and amazing people. ”</h3>

    </div>

  </div>
</body>

</html>

Answer №1

Consider setting a minimum-width parameter in your media query and updating the width attribute of the container class to be maximum-width.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The sizing of Bootstrap Inline dropdown menus is not accurate

I want to create two dropdown menus using Bootstrap v3 that are displayed side by side with a specific width and utilizing the grid system. However, I am facing an issue where the width remains the same. Here is an example of what I mean: .menuList > ...

Displaying live data from an XMLHttpRequest in a Vue component in real-time

I'm currently working on implementing lazy loading for a list of posts fetched from the WordPress REST API. My goal is to load additional news stories upon clicking an HTML element. However, I'm facing issues with accessing the original Vue inst ...

Guide to inserting text into an html element upon clicking an ASP:Button

In my code, there is a DIV that holds some text. Accompanying the text is an asp:Button. When this button is clicked, I aim to access and save this particular text. Nonetheless, it seems that once the button is clicked, the content of the DIV resets - lik ...

Issues with the plugin for resizing text to fit the parent div's scale

I've spent the last hour attempting to get this script to function properly, but no luck yet. Check out the correct jsfiddle example here: http://jsfiddle.net/zachleat/WzN6d/ My website where the malfunctioning code resides can be found here: I&apo ...

Ensure that Mathjax underscores are consistent with the height of other characters

Presented below is the latex code being used with Mathjax. \class{mathjaxCursor}{\text{_}} ...and here is the accompanying css: .mathjaxCursor { font-weight: bold; background-color: red; } This setup results in the following display: ...

How come the hidden container does not reappear after I click on it?

I'm having an issue with a hidden container that holds comments. Inside the container, there is a <div> element with a <p> tag that says "Show all comments". When I click on this element, it successfully displays the comments. However, cli ...

The checkbox filter in Angular 6 has the ability to replace the previously selected

I've been working on creating a filter system using checkboxes. Below is a snippet of the code I'm currently using: filter.pipe.ts import { Pipe, PipeTransform, Injectable } from '@angular/core'; @Pipe({ name: 'filter2' }) ...

Hide the border below the active tab

Could anyone assist me in removing the border below the selected tab? I've attempted multiple approaches without success. I experimented with adding a negative margin to the tab and creating a white border, but as the border I want to conceal is from ...

Display a JavaScript variable as an attribute within an HTML tag

let disableFlag = ''; if(value.action.length === 0) { disableFlag = 'disabled="disabled"'; } row += '<td><input type="checkbox" name="create" value="1" class="checkbox" data-action="'+ value.action + '" data-co ...

Access the website by logging in with idhttp

I'm attempting to log in to a website using Delphi / Indy. Currently, I only have a button (used to send a password / username) that calls this procedure. procedure TForm5.Login(name: string; Pass: string); var UserID :string; Password :string; res : ...

Make sure the navigation bar is fixed to the top of the page only

Looking for a solution to stick the navigation menu to the top of the screen only when the screen is wider than 782px. Progress so far: https://jsfiddle.net/ah4ta7xc/1/ Encountering an issue where there is an unintended gap at the top when applying the s ...

What is the reason that when a <div> click on a mobile device includes a jQuery ('#item').fadeOut() function, the CSS of the '#item' element maintains its previous hover state

While creating a mock back to top button, I encountered an issue with my jQuery call to fadeOut() behaving differently on mobile devices (this discrepancy can be observed using any desktop browser simulator). You can find the source code here: https://cod ...

Discover the process of transitioning your animations from Angular to CSS

I have successfully implemented a fade-in/out animation using @angular/animation, but now I am looking to transfer this animation to CSS and eliminate the dependency on @angular/animation. Here is my current animation setup (triggering it with [@fadeInOut ...

The select2 jQuery plugin is malfunctioning following an AJAX request to update the HTML content

I have implemented an AJAX function to change the content of a HTML div. Within this changed content, there is a select box with the 'select2' jQuery class. However, after the AJAX load, the select2 jQuery plugin does not work properly. Here is ...

Manipulate Attributes in Javascript

Having an issue here - I'm trying to use JavaScript to set some attributes. for(i=0;i<div_navi.childNodes.length;i++){ if(div_navi.childNodes[i].nodeName =="SPAN"){ div_navi.childNodes[i].setAttribute("onclick","g ...

Container struggling to contain overflowing grid content items

While creating a grid in nextjs and CSS, I encountered an issue. Whenever I use the following code: display: grid; The items overflow beyond the container, even though I have set a maximum width. Instead of flowing over to the next row, the items just kee ...

Creating a CSS template for organizing sidebar and footer divisions on a webpage

I am facing an issue with the layout of my website. I have a container that is positioned relatively and houses various divs for header, sidebar, main-content, and footer. The problem lies with the sidebar and footer components. The sidebar has been posit ...

Exploring the capabilities of HTML5's file API along with Octokit.js to work with

I have been trying to create a form that allows users to upload binary data to GitHub using octokit.js. However, every time I attempt to do so, the data ends up corrupted on the GitHub side. Here is a minimal working example: http://jsfiddle.net/keddie/7r ...

What could be the reason behind Flex making several images decrease in size?

I'm trying to set up a carousel of images with Tailwind CSS, where 5 identically sized images are displayed next to each other and can be scrolled left and right. When I imported the images without using Flex, they fit the max-width that I had specifi ...

Create a shiny application that makes text bold in the user interface

Can someone please guide me on how to make specific words bold in a sentence within the UI using HTML tags under the h() function? Your assistance is greatly appreciated. Thank you. library(shiny) ui <- navbarPage( title = 'Benvenuto&apos ...