Media query failing to adjust properly

On my website's "about" page, I'm attempting to implement a media query but encountering an issue. In the original CSS, I structured the "information" section into 2 columns with right padding to prevent the content from extending all the way to the screen edge. However, when applying the media query, the padding and grid layout remain unchanged, creating unnecessary extra space on the right side of the website. How can I adjust this?

I've attempted modifying these properties within the media query, but it doesn't seem to have any effect on the website: grid-template-columns: repeat(1,1fr) padding-right: 0px;

        <!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Portfolio</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" type="text/css" media="screen" href="css/main.css" />
    <link rel="stylesheet" href="https://unpkg.com/@blaze/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="395a4a4a790a170b1709">[email protected]</a>/dist/blaze.css">
    <link href="https://fonts.googleapis.com/css?family=Didact+Gothic" rel="stylesheet">
    <script src="https://unpkg.com/@blaze/ [email protected]/dist/blaze-atoms.js"></script>
    <script src="javascript/main.js"></script>
    <script src="javascript/jquery.js"></script>
</head>
<body>
        <div class="cotainer">
                <div class="title">
                    About Me!
                </div>
                <div class="information">
                        <div class="span-row-2">
                                <img src="images/profile.svg" id="logo">
                        </div>
                        <div class="tabs">
                                <input type="radio" name="tabs" id="tabone" checked="checked">
                                <label for="tabone">Education</label>
                                <div class="tab">
                                  <h1 class="phrase">San Jose State University</h1>
                                  <blaze-divider class="divider">Major</blaze-divider>
                                  <div class="major">Digital Media Art</div>
                                </div>

                                <input type="radio" name="tabs" id="tabtwo">
                                <label for="tabtwo">Contacts</label>
                                <div class="tab">
                                  <h1 class="phrase">Stay in touch!</h1>
                                  <blaze-divider class="divider">Get Connected</blaze-divider>
                                  <div class="socials">
                                      <a href="https://www.facebook.com/thanh.truong.3597" class="icons" target="_blank">Facebook</a>
                                      <a href="https://www.instagram.com/thanh_be_like/" class="icons" target="_blank">Instagram</a>
                                      <a href="https://www.linkedin.com/in/thanh-truong-918509163/" class="icons" target="_blank">Linkedin</a>
                                      <a href="creative_resume.pdf" class="icons" target="_blank">Resume</a>
                                  </div>
                                </div>
                </div>
            </div>
            <nav id="mainnav" class="group">
                <div id="menu">&#x2261; Menu</div>
                <ul>
                   <li><a href="about.html" class="active">About</a></li>
                   <li><a href="index.html">Home</a></li>
                   <li><a href="portfolio.html">Portfolio</a></li>
                </ul>
            </nav>
            <script>
                    $(document).ready(function() {

           // JQUERY NAV TOGGLE
           $('#menu').bind('click',function(event){
               $('#mainnav ul').slideToggle();
           });

           $(window).resize(function(){  
               var w = $(window).width();  
               if(w > 768) {  
                   $('#mainnav ul').removeAttr('style');  
               }  
           });

         });
            </script>

</body>
</html>




  information {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    padding-right: 50px;
    background:#323526;
    padding-bottom: 50%;
}
.span-row-2{
    grid-row: span 2 / auto;
    align-items: center;
    margin:10vw;
}
.tabs {
    display: flex;
    flex-wrap: wrap;
}
.tabs label {
    order: 1; 
    display: block;
    padding: 1rem 3rem;
    margin-top:70px;
    cursor: pointer;
    transition: background ease 0.2s;
    width:50%;
    text-align: center;
    border-bottom: 1px solid #C28710;
    color: #C28710;
    font-size: 1.5vw;
    letter-spacing: 2px;
}
.tabs .tab {
    order: 99; 
    flex-grow: 1;
    width: 100%;
    display: none;
    padding: 1rem;
}
.tab{
    border-radius: 0px 0px 20px 20px;
    background-color: rgba(0, 0, 0, 0.2);
}
.tabs input[type="radio"] {
    display: none;
}
.tabs input[type="radio"]:checked + label {
    border-bottom: 4px solid #C28710;
    font-weight: bold;
}
.tabs input[type="radio"]:checked + label + .tab {
    display: block;
}

@media (max-width: 45em) {
  .tabs label,
  .tab .tabs {
    order: initial;
  }
  .tabs label {
    width: 100%;
    margin-right: 0;
    margin-top: 2rem;
  }
}

@media all and (max-width:650px){
    .span-row-2{
        grid-row: span 2 / auto;
        align-items: center;
        margin:40px;
        min-width:250px;
        min-height: 250px;
        grid-area: main;
    }
    .tabs label {
        order: 1; 
        display: block;
        margin-top:20px;
        cursor: pointer;
        transition: background ease 0.2s;
        width:50%;
        text-align: center;
        border-bottom: 1px solid #C28710;
        color: #C28710;
        font-size: 15px;
        letter-spacing: 2px;
    }
    .information{
        grid-template-columns:repeat(1,1fr);
        padding-right:0px;
    }
}

Current Layout Image Desired Layout Image

Answer №1

It appears there may be some confusion regarding the intended outcome in this situation. An observation I made is a potential conflict between the rules specified in your two media queries.

The directives within the max-width:45em media query are being overridden by those within the max-width:650px

I trust this information proves helpful. ¯\_(ツ)_/¯

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

Exploring the possibilities of ReactJS and the sleek design of

How can I alter the background color of a RaisedButton without having the CSS class name appear in the autogenerated div? Here is the button: <RaisedButton className="access-login" label="Acceder" type="submit"/> This is the specified CSS: .acces ...

Creating and implementing a HTML template from scratch, devoid of any frameworks

Is there a way to create a quiz where all questions follow the same format and only one question is displayed at a time, without duplicating code? Perhaps using a template would be the ideal solution in this scenario. I appreciate your help. ...

Modifying the page header content using JavaScript

There's this snippet of code that alters the image on another page: <div class="imgbx"> <button onclick="window.location.href='index.html?image=images/xr-black.jpg&tit=XR-black'" >Invisible ...

Which is more accessible: a disabled textbox or a div with role="textbox"?

Imagine I have a form in which one of the fields (name) is always disabled. When it comes to accessibility, would it be more effective to use an input <label> Name <input role="textbox" aria-readonly="true" value="Joe Shmoe" /> < ...

Do you know where I can locate the HTML and CSS pertaining to the search results page

I'm looking for a way to present search results on my website that resembles the Google search results, creating a familiar interface for users. Is there anyone who knows where I can obtain the HTML and CSS code that produces the same style as Google& ...

unable to execute PHP code

I am attempting to execute a PHP file that will update a database. On Chrome, I am encountering this error: This is the code I have in my index.html file: <!DOCTYPE html> <html> <body> <input type="text" id="descriptioninput"> ...

Leveraging the power of PHP includes with nested subdirectories

Hello, I recently configured my web server to run all .html files as .php files, allowing me to utilize the php include function, which has been very beneficial. However, I have various subdirectories with multiple files in each one. Homepage --banners ...

Display a fresh <p> tag when the condition in the if-statement is met

If you are looking for a questionnaire, check out this one. Now, I am interested in creating if-statements using HTML/CSS/jQuery to achieve the following scenario: Initially, only Question 1 will be visible. When the input matches a certain value like X, ...

Adjust the alignment and floating of text within an iframe on the same domain

Is it possible to align text on the right side of an iframe that contains a width and text inside? The iframe's src is from the same domain. If so, how can this be achieved through JavaScript? ...

Red X appearing in IE9 for HTML5 Video

It's strange that my video works on some browsers but not others, even though I'm using mp4, ogv, and webm formats. Even weirder is that some videos work while others don't. To illustrate the issue, I've created a jsfiddle for you to c ...

Should comments come before <!DOCTYPE HTML>?

When organizing my files, I always start with a comment about the content. However, I've been told that it's not recommended to put anything before the declaration. Is it acceptable to include comments before this or should I reserve the top of m ...

What are the steps to designing a Vertical Curve UI?

Is there a way to replicate the unique vertical curve on the login page, as shown in the image below? I've come across horizontal SVGs that can achieve this effect, but I'm struggling to find resources on implementing it vertically. How is this ...

Having trouble getting a dropdown menu to function properly with jQuery

Within my project, I have implemented a menu that transforms into a dropdown menu for smaller screens. Below is the HTML code for this functionality: <select> <option value="index.php" id="home">Home</option> <option value="about ...

Why does my element appear to be a different color than expected?

I've developed a sleek wind map (check out for reference). Using a weighted interpolation every 10ms, I generate uVector and vVector data to calculate wind speed. Based on this speed, each point is assigned a specific color as outlined below. if (we ...

Accessing PHP parameters in JSP files can be accomplished by utilizing specific

The PHP code snippet below checks for a username and password match before redirecting to a JSP page. if($userName==$dbUserName&&md5($passWord)==$dbPassWord){ echo "<input name='username' type='hidden' value='$userN ...

Is the space-between property not delivering the desired spacing?

I am trying to achieve equal spacing between list items, and I attempted the following code. ul { list-style-type: none; display: flex; justify-content: space-between; } However, it seems that this approach is not working as expected. I am confused ...

Step-by-step guide on triggering a button using another button

I have a unique question that sets it apart from others because I am looking to activate the button, not just fire it. Here is my syntax: $("#second_btn").click(function(){ $('#first_btn').addClass('active'); }) #first_btn ...

What is the best way to create distance between my buttons?

Can anyone help me with an issue I'm facing where adding margin to my buttons is causing the last button to jump down a row? I have an idea of what might be happening but I'm unsure how to solve it. Below is the CSS code for the buttons, any sugg ...

Can anyone provide guidance on locating the parent of a pseudo element with Selenium WebDriver?

Is there a way to retrieve the parent web element of a pseudo element (if we can call it the parent) using JavaScript? I know that Selenium's methods for searching for web elements are not suitable for pseudo elements, but JavaScript does allow manipu ...

What is the best way to activate a progress bar upon clicking a button in an HTML document?

Is it possible to make a progress bar start moving upon clicking a button using only HTML? I am new to coding (just started today) and would appreciate some guidance on how to achieve this. This is what I currently have: <input type="image" src="Butto ...