Why aren't my laptop media query CSS styles being applied?

My laptop size media query is not applying the CSS styles I want. I have tried using both min and max width but without success. I am trying to replicate the layout found here:

@media screen and (min-width: 960px) and (max-width:1199px){
  
 
  .grid-container {
    display: grid;
    grid-template-columns: repeat(3, 30vw);
    /* grid-template-rows: 430px 250px; */
    grid-template-rows: auto auto;
    padding: 0px;
    margin: 50px 0px 50px 0px;
 
   
  }
  .featureLeft{
    position: relative;
    right: -30px;
    
  }
  .featureRight{
    position: relative;
   left: 50px;
  }
  .marginBottom{
    position: relative;
    bottom: 30px;
   }

  .features{
    width:400px
  }
  
  p{
    font-size: 16px; 
  }
  h1{
    font-size: 25px;
  }
  h2{
    word-wrap: break-word;
    font-size: 1.125rem;
    
    
  }
  .grid-container>div {
  
    text-align: left;
    padding: 30px
 
 
  } 

  .container {   
     width: 90%;  
     margin-left: 10px;
     
    } 

  .the-feed {
    grid-area: 1 / 1 / 3 ;
    margin-left: 160px;
    
  }

  .feed-image{
   height: 305px;
   margin-top: 50px;
   width: 200px;
   position: relative;
   right: 30px
  } 

}




/* desktop styles */
@media screen and (min-width: 1200px){
  
  
  
  .grid-container {
    display: grid;
    grid-template-columns: repeat(3, 30vw);
    /* grid-template-rows: 430px 250px; */
    grid-template-rows: auto auto;
    padding: 0px;
    margin: 50px 0px 50px 0px;
    

    
   
  }


  .featureLeft{
    position: relative;
    right: -30px;
    
  }
  .featureRight{
    position: relative;
   left: 50px;
  }
  .marginBottom{
    position: relative;
    bottom: 30px;
   }

  .features{
    width:400px
  }
  
  p{
    font-size: 16px; 
  }
  h1{
    font-size: 25px;
  }
  h2{
    word-wrap: break-word;
    font-size: 1.125rem;
    
    
  }
  .grid-container>div {
  
    text-align: left;
    padding: 30px
 
 
  } 

  .container {   
     width: 1300px;  
     margin-left: 20px;
     
    } 

  .the-feed {
    grid-area: 1 / 1 / 3 ;
    margin-left: 160px;
    
  }

  .feed-image{
   height: 305px;
   margin-top: 50px;
   width: 200px;
   position: relative;
   right: 30px
  } 

}

I have managed to get the grid layout working, but on my desktop, the spacing seems off. When I try to bring the features closer together, it impacts the layout on my laptop even though I have separate media queries set up.

Here is my codepen link for reference: https://codepen.io/shuibcodes/pen/xxqWajO

Answer №1

It appears that the media query styles for your laptop are being applied, but they do not seem to be styled correctly according to the reference you provided.

Here are some suggested fixes:

@media screen and (min-width: 960px) and (max-width: 1199px) {
  .grid-container {
    display: grid;
    grid-template-columns: repeat(2, 50vw); //Update
    
    ....

   .the-feed {
    grid-column: 1/-1; //Update
  }

For a full example, check out this link: https://codepen.io/AravinthAro/pen/gOmeqjJ

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

Design your HTML select element with a unique custom arrow where the text elegantly appears over the arrow

I've encountered an issue with a select element in my HTML page that has a custom arrow. The problem is that the text within the select element overlaps with the arrow, which is not desired. I'm seeking a cross-browser solution for this specific ...

What is the best way to obtain a distinct collection from two arrays that eliminates the second appearance of an element based on a key's value, rather than the first as in the Lodash uniqueBy function?

Let's say I have two arrays... const arr1 = [ { id: 1: newBid: true } ]; const arr2 = [ { id: 1, newBid: false }, { id: 2, newBid: false } ]; My goal is to end up with an array that looks like this [ { id: 1, newBid: false }, { id: 2, newBid: fals ...

I am looking to modify the anchor link and image source using JQuery based on the specific div ID

Looking to update the link of an anchor and source of an image inside this div when clicking on the FR button. I need help figuring out how to do this with JQuery. Here's the code: <div id="my_id"> <a href="wwww.google.com&qu ...

middleware that executes prior to any route handlers

Currently, I'm working on implementing token-based authentication. I've encountered an issue with running authentication before any requests are made. Specifically, I need to check if the request has a valid token before proceeding. Below is an ...

What is the best method for emulating ui-sref from an ng-swipe event?

State Change Triggered by Swipe: I am trying to change the state of my application using a swipe event. I have looked at the ui-router documentation which suggests using $state.go(), but I'm not sure if this is the best approach? QUESTION: How can I ...

The issue with Firefox's DOMContentLoaded event

After creating a script that interacts with the Dom, I noticed that it needs to wait until the Dom is ready before executing each operation. My intention is to make this script usable in two ways: Include it in the head tag, ensuring it loads before the ...

What is the best way to activate a post function using a hyperlink?

I'm struggling to figure out how to call my post function using a link within my navbar. The issue is that I'm working with links in the navbar code, and not sure how to integrate calling the post function with them. Below is the code for my pos ...

shard: the dropdown menu can be interacted with by clicking, but the options

Having trouble selecting an item from a dropdown menu on a modal using splinter. Despite the dropdown being visible and clickable, the selection is failing unexpectedly. (Pdb) dropdown = next(i for i in my_browser.find_by_xpath('//select[@name="exist ...

The child directive has the ability to interact with every parent directive

I am attempting to create a slider using angularJS. Within this slider, I have implemented a child directive with event listeners. Whenever the main event (mousedown) is triggered, it invokes a function from the parent directive through a controller and up ...

A guide to sharing session variables with express views

Struggling to access session variables in EJS views and encountering various challenges. To locally access req.session, I've implemented middleware as outlined in this guide on accessing Express.js req or session from Jade template. var express = re ...

Next.js API route is showing an error stating that the body exceeds the 1mb limit

I'm having trouble using FormData on Next.js to upload an image to the server as I keep getting this error. I've tried various solutions but haven't been able to resolve it yet. This is my code: const changeValue = (e) => { if (e.target ...

How can I implement the useState hook in server side rendering with Next.js?

Seeking a way to pass a value from the client side to the server side has been challenging. While useState is not available for use on the server side, there must be an alternative solution. The goal is to fetch a value from the client and incorporate it ...

Iconic slim template for data disabling

Having an issue while working on a Rails app with slim. I am facing a problem passing HTML to slim through a button using the data-disable-with attribute. My aim is to display an icon on the button when it's clicked. = f.submit t("basket.next_step") ...

Alternative Options for Playing Audio in Internet Explorer 8

I'm in the process of setting up a button that can both play and pause audio with a simple click. While this functionality is working smoothly in modern browsers like Google Chrome, I am facing compatibility issues with IE 8. Even after attempting to ...

Arranging div elements with CSS styling

I always struggle with CSS layouts and positioning 'div' elements on the page. For instance, I have created the following structure: Check out my jsfiddle: http://jsfiddle.net/JJw7c/3/ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitiona ...

Is it possible to integrate Material Icons with a PrimeReact button?

At the moment, I am utilizing Button from PrimeReact. They utilize icons from PrimeIcons which have a limited number of options. However, I would like to incorporate Material Icons into my buttons. <Button label='View/Edit Job' icon="pi p ...

Protractor: Unable to reach variables within closure set in the parent function

I have a code snippet in one of my JS files that looks like this: // test/lib/UserHelper.js 'use strict'; var Firebase = require('firebase'); exports.createUser = function (email, password) { browser.executeAsyncScript(function (do ...

The HTML footer designed with bootstrap is not behaving as expected. It is not staying fixed at the bottom of the page and is not displaying at full width despite my coding efforts

Working on a small Sinatra app with bootstrap for layout, I'm encountering some issues. The layout is not sticking to the bottom and not displaying at 100% width as intended. Additionally, the footer text is not centering even after applying the text ...

Verify the level of opacity in the image

I'm working on a website that allows users to upload PNG images and save them. However, before they can save the image, I need to check if it contains transparency. Is there a way to determine if an image is not 24-bit using JavaScript? <img id= ...

Using JavaScript/JQuery to Access an External SQLite Database

Is there a way to incorporate my own SQLite database into a website using JavaScript and JQuery? I've searched for examples but have yet to find any helpful articles on the topic! ...