Challenges arise when media queries fail to activate properly

Greetings! I am currently working on enhancing the responsiveness of my webpage using Media Queries. However, I seem to be facing a challenge with the second image not changing as expected when I reduce the browser size.

In the HTML, 'top-background-image' is defined as the background image for a specific div, while 'profile-pic' is a standalone photo on top of that background. Despite making adjustments to 'profile-pic' within the media query, I am unable to see any changes reflected in the output when the browser size is decreased.

Additionally, I am encountering an issue where the text alignment for 'baker' and 'joe' is off-center even though I have specified 'text-align: center'. This occurs when the browser size is decreased.

Seeking assistance on resolving these issues! :)

Here is the relevant HTML code snippet:

  <div >
      <div >
      <img className="top-background-image" src="**image1.jpg**" alt="background-image"/>
      </div>
      <div className = "top-container">
      <h1 className = "joe animate__animated animate__fadeInLeftBig ">Hi, I'm Joe.</h1><span><h2 className="baker animate__animated animate__fadeInRightBig animate__delay-1s" >a baker for you.</h2></span>
      <img className ="profile-pic animate__animated animate__fadeInUpBig animate__delay-2s"src="**image2**.jpg" alt="profile"/>
      <a className = "scroll" href="#middle-container"><FontAwesomeIcon className="social-icon" icon={faAngleDoubleDown} bounce size = '2x' color = "white"/></a>
      </div>
    </div>  

Here is the corresponding CSS code:

    .top-background-image {
  position: relative;
  filter: blur(4px);
  -webkit-filter: blur(4px);
  width: 1600px;
  height: 800px;
  margin-bottom: 10px;
} 

      .top-container {
      display: flex;
      justify-content: center;
      text-align: center;
    }


   .joe {
  font-family: "Droid+Sans";
  font-weight: normal;
  color: #ffffff ;
  font-size: 7rem;
  position: absolute;
  top: 17%;
  left: 32%;
}

.baker {
  font-family: 'Satisfy', cursive;
  font-weight: normal;
  color: #ffffff;
  position: absolute;
  top: 37%;
  right: 21%;
}

.profile-pic { 
  display: inline-block; 
  height: auto; 
  width: 250px;
  border-radius: 50%;
  position: absolute;
  top: 48%;
  left: 43%;
  margin: auto;
  display: block;
  
}

And here is how it looks within the media query:

@media (max-width: 900px){

 .top-background-image {
    position: relative;
    left: 50%;
    transform: translate(-50%, 0);
    -ms-transform: translate(-50%, 0);
    -webkit-transform: translate(-50%, 0);
    width: 100%;
}

      .joe {
        font-size: 3.5rem;
        margin: 0 auto;
      text-align: center;
        
      }
    
    .baker {
      text-align: center;
      margin: 0 auto;
      font-size: 1.5rem;
     
    }
    
      .profile-pic {
        display: block;
        margin: 0 auto;
        width: 150px;
      width: 150px;
      }

}

Answer №1

After experimenting, I managed to discover the solution on my own. It seems that in my particular scenario, I had to include 'screen and' after @media to achieve the desired result:

@media screen and (max-width: 900px)

After making some minor adjustments, everything is now functioning perfectly. Hopefully, this information will benefit someone else in the days to come.

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 parameters 'event' and 'payload' do not match in type

Upon running the build command, I encountered a type error that states: Type error: Type '(event: React.FormEvent) => void' is not assignable to type 'FormSubmitHandler'. Types of parameters 'event' and 'payload&apos ...

The email verification link page API encountered an error as the server responded with a status of 400 (Bad Request), leading to the failure in loading the resource

After confirming that the backend is working smoothly with Postman, I encountered an issue when running the code on the client side. The error message states: "Failed to load resource: the server responded with a status of 400 (Bad Request)" The following ...

Only CSS creates tooltips within text seamlessly without any line breaks

I have been exploring ways to incorporate multiple tooltips into text on my website. After experimenting with both span and div tags, I was able to create a tooltip using CSS only. However, I am facing challenges with positioning the tooltiptext correctly. ...

Greek symbols do not display correctly in SQL Server when accessed through PHP

At my server database, there is a table with collation set to greek_ci_ai, but I am facing an issue where Greek characters are displaying as question marks(????). I have attempted using header("Content-Type: text/html; charset=iso-8859-7") and <meta ...

Troubleshooting the issues with implementing cross-browser jscrollpane functionality

Hey there! I've been exploring this tool to customize the default scroll-bar, and here's a fiddle showcasing my experimentation. In the fiddle, I've included the following code snippet <div class="scroll-pane horizontal-only">(located ...

The visibility of a decal on a three.js bottle will vary depending on the angle of the camera

After creating a 3D bottle using Blender, my plan is to integrate it into a website with three.js for rotation purposes. To achieve this, the appearance of the bottle needs to be consistent from all angles, which may involve using OrbitControls. I have a ...

Displaying images dynamically in React from a source that is not public

There are 3 image options being imported, determined by the value in the state which dictates which of the 3 to display. import csv from '../../images/csv.svg'; import jpg from '../../images/jpg.svg'; import png from '../../images/ ...

Performing a function when the ondrop event of a <li> element is triggered

Is there a way to trigger a code-behind click function on the ondrop event of an <li> element? Additionally, I would like to know if it's possible to force a postback on the onclick event. Any ideas on how to achieve this? Just to clarify, thi ...

Creating a responsive design that adapts to various image sizes

In my API response, I am receiving images of various sizes. To display these images on my HTML page, I have created a table containing 4 images. To ensure responsiveness, I have set the width of the table to 100%, each row (tr) to 100%, each cell (td) to 2 ...

What is the best way to eliminate the space between two paragraphs?

Check out my awesome image! I need some help with formatting HTML data into text. Can anyone advise me on how to eliminate the space between two paragraphs? func processGetDescriptionResponse(json: JSON) { let status = json.dictionaryObject!["statu ...

Steps for resolving the error message: "An appropriate loader is required to handle this file type, but there are no loaders currently configured to process it."

I am encountering an issue when working with next.js and trying to export a type in a file called index.ts within a third-party package. Module parse failed: Unexpected token (23:7) You may need an appropriate loader to handle this file type, current ...

Is it achievable to animate the offset with React Native Animated?

I am attempting to develop a dynamic drag and drop functionality, inspired by this example: My goal is to modify it so that when the user initiates the touch, the object moves upwards to prevent it from being obscured by their finger. I envision this move ...

Once the image is requested in HTML, three.js makes a subsequent request for the same image

This is a block of code. let image = new THREE.TextureLoader().load("http://odf9m3avc.bkt.clouddn.com/1493817789932.jpg") <script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/88/three.min.js"></script> <img class='preLoad&apo ...

Combining a Vuetify 2 toolbar and a navigation drawer, topped with an additional toolbar for added functionality

I am working towards achieving a layout similar to this: https://i.stack.imgur.com/M0rGl.jpg However, I currently have this setup: https://i.stack.imgur.com/VOGxJ.jpg The issue I am facing is that I am unable to position the first toolbar above the navi ...

React encountered an abrupt end of JSON input unexpectedly

As I embark on my coding journey, I am delving into the world of React. However, as I try to create a new app, I encounter an error message stating "unexpected end of JSON input." While installing packages and waiting patiently, the console throws an err ...

What is the process for switching directories and renaming a file when uploading in nodeJs?

I am currently using multer and fs to handle the upload of an image file. How can I modify the directory where uploaded files are stored? Currently, all files are saved in my "routes" folder instead of the "uploads" folder created by multer. Additionally, ...

What is the most effective method for importing .module.scss classes in a React project?

In the midst of my NextJs project, I have encountered two different methods for importing CSS classes from a .module.scss file. Method 1: import * as styles from './page.module.scss'; Classes are used like this: <div className={styles.myCla ...

Glistening R resize plotOutput

Attempting to resize a plotOutput using Shiny R. The plot in question can be viewed https://i.sstatic.net/fgzag.png This is the code snippet: #In ui: fluidRow( column(width = 12, h4("Diagrama Persistencia"), plotOutput("Dia ...

Tips for causing text to wrap to a new line when reaching the end of a div element

I am struggling with keeping a text inside a div from overflowing when it reaches the border of the div. I have tried various CSS properties like "word-break" and overflow, but haven't been able to find a solution. <div class="col-lg ...

Is it possible to convert MUI components into strings on the client side?

I have incorporated the Material UI (MUI) library into my React application and am currently attempting to display certain components as PDF files directly in the browser. The approach I am taking involves: Creating a React element Rendering the React el ...