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

Altering the text and functionality of buttons with jQuery

A JavaScript method I have is designed to change based on the state of a button, which is determined by using indexOf("..some text.."). $('#add1').click(function(){ if($(this).text().indexOf("Add Me!")) { $.ajax({ type: & ...

Merging backend code (Java and Python) into HTML for seamless integration

While I have a solid background in back-end coding languages like Java and Python, the task at hand requires integrating this code into a website. The backend code comprises various methods and classes to encrypt text messages using encryption techniques ...

Retrieving addresses by extracting p from the Python class within a div

Currently the code: Extracts URLs for various gyms and saves them in a CSV file as shown below: https://www.lifetime.life/life-time-locations/al-vestavia-hills.html https://www.lifetime.life/life-time-locations/az-biltmore.html Desired functionality: I&a ...

Having difficulty viewing the images clearly

My JavaScript codes for scrolling images are not displaying all the images when viewed on Google Chrome. Is there a solution available? Below is the included JS code and CSS. data=[ [" images/img1.jpg"," Image1","pic01.jpg"], [" images/img2.jpg","Image2 " ...

Notification (jQuery) failing to display user messages

Is there a way to retrieve the post title and display it in a notification? The notification's title is extracted from a form and shown in the notification. When the user clicks the submit button, the system captures the duration and title, displaying ...

Is it possible to place Angular Material components using code?

Currently, I'm in the process of creating a responsive Angular application. Is there any way to adjust the height and position of the <mat-sidenav-content></mat-sidenav-content> component in Angular Material programmatically without relyi ...

Uncovering Inline Styles Infused with Javascript for Effective Debugging of Javascript Code

SITUATION: I have recently inherited a website from the previous developer who has scattered important functions across numerous lengthy JS files. I am struggling to track down the source of an inline CSS style within the JS or identify which function is d ...

Chrome has some issues with resizing the SVG Pattern element

Utilizing inline svgs, I have a svg circle filled with a pattern that should cover 100% of the container size. However, when the parent element is resized via JavaScript, the pattern no longer reflects the 100% width and height as expected. This issue seem ...

The button event is currently only targeting the initial class. (Jquery)

I am having an issue where only the first instance of the saveBtn class is being saved into local storage when clicked. Can anyone provide some assistance with this? Here is the HTML: <div class="hour-container" id="8am"> & ...

The index.html file is not displaying correctly on a servlet 3.0 configuration with Tomcat

I am currently working on a basic web application using Servlet 3.0 with Tomcat 7.0.25, and deploying the application as a war file named mywebapp.war. The structure of the war file is as follows: mywebapp/index.html mywebapp/META-INF/MANIFEST.MF myweba ...

Display the jQuery validation message in the final td cell of the table

JavaScript Animation Library rules:{ gender: { required: true }, }, messages:{ gender: { required: "Please indicate your gender" }, }, errorPlacement: function (error, element) { if (element.attr("type") == "radio") { ...

Accordion Tuning - The Pro and Cons

Here is a functional accordion that I've implemented, you can view it here This is the JavaScript code I am using: $(document).ready(function ($) { $('#accordion').find('.accordion-toggle').click(function () { //Expa ...

Implement Angular backend API on Azure Cloud Platform

I successfully created a backend API that connects to SQL and is hosted on my Azure account. However, I am unsure of the steps needed to deploy this API on Azure and make it accessible so that I can connect my Angular app to its URL instead of using loca ...

Issue: Animation not triggered on exit by React-transition-group Transition

I am aiming to create a unique animation where an icon spins 90 degrees to become flat and then seamlessly transitions into another icon, simulating a coin-spin effect. The desired effect is for the icons to spin both on enter and exit, although there may ...

Instructions on creating a Superfish menu with a vertical layout in the first level and a horizontal layout in the second level

Currently, I am using the Superfish menu in Drupal7 and have designed my first item level to be vertical. However, I now want to style my second item level horizontally. I have tried various CSS approaches and added some class names via jQuery like $(&apo ...

Ways to stop a background image from repeating?

<div style="background-image: url('https://i.ibb.co/v1B855w/bg15.png'); color: #000000; background-color: #000000; background-attachment: fixed; text-align: center;"><img src="https://i.ibb.co/L6zQY0S/name6.png" /> ...

Enlarging an image on canvas and creating a repeating pattern

My canvas size is 500px x 500px. I have a png image that matches the canvas size, which you can view here. I am looking to resize the image to 100px x 100px and then use it as part of a repeat pattern on the canvas. This is how I achieve this: // First d ...

Tips for leveraging Backbone.js for creating dynamic single page websites

I am eager to create my own personal website with a unique functionality similar to this example: The idea is to have the entire website contained within a single HTML page, where clicking on a navigation item will dynamically load only the necessary info ...

The background image is failing to display

I am currently working on a subpage for my website that includes a navigation bar and footer. I am looking to add a background image behind the navigation bar, similar to this design. https://i.stack.imgur.com/j6fDZ.jpg After trying various methods, I at ...

Guide to modifying the text color of a Primefaces/jqPlot line chart:

I've implemented a basic JSF line chart with PrimeFaces (using jqPlot library) in my project: <p:lineChart id="linear" value="#{team.chart}" title="Lap Times" xaxisLabel="Lap" yaxisLabel="Time ...