Dynamic Column Image and Text Display

I am working on a website where I am trying to have an image on the left and a paragraph on the right, but when the screen size is reduced, I need the layout to switch so that the image is at the top and the paragraph is at the bottom.

Even though I have implemented this layout before, it doesn't seem to be working properly this time. I have searched online and looked at other examples, but I can't figure out what the issue is. Can someone assist me with troubleshooting? I'm sure it's a simple fix that I just can't see right now.

Here is the HTML code:

<h1>About</h1>
  <div class="wrapper">
  <img src="image.jpg" alt="image" id="img-about">
  <p id="text-about">Lorem ipsum dolor sit amet consectetur adipisicing elit. Alias perspiciatis asperiores in aliquid repudiandae blanditiis recusandae molestiae nemo itaque inventore velit illum vel voluptatibus, eveniet repellat facilis consectetur veritatis deleniti explicabo ducimus! Debitis numquam unde necessitatibus esse sed. Earum accusamus itaque autem reiciendis aliquam laboriosam sint rem illo explicabo culpa?</p>
</div>

And here is the CSS code:

.wrapper {
  display: flex;
  flex-direction: row;
}

#about-img {
  width: 250px;
  height: 250px;
  border-radius: 50%;
  padding: 10px;
  margin-right: 15px;
}

#text-about {
  font-size: 14px;
  margin: auto;
  padding: 5px;
}

@media (max-width: 800){
  .wrapper {
    flex-direction: column;
  }
}

Answer №1

Your media query needs the unit of measurement to be specified.

Update

@media (max-width: 800){
  .container {
    display: block;
  }
}

with

@media (max-width: 800px){
  .container {
    display: block;
  }
}

Answer №2

You need to include the unit for your media queries.

 @media (max-width: 800px)

.wrapper {
  display: flex;
  flex-direction: row;
}

#about-img {
  width: 250px;
  height: 250px;
  border-radius: 50%;
  padding: 10px;
  margin-right: 15px;
}

#text-about {
  font-size: 14px;
  margin: auto;
  padding: 5px;
}

@media (max-width: 800px){
  .wrapper {
    flex-direction: column;
  }
}
 <h1>About</h1>
  <div class="wrapper">
  <img src="https://images.pexels.com/photos/586744/pexels-photo-586744.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500" alt="image" id="img-about">
  <p id="text-about">Lorem ipsum dolor sit amet consectetur adipisicing elit. Alias perspiciatis asperiores in aliquid repudiandae blanditiis recusandae molestiae nemo itaque inventore velit illum vel voluptatibus, eveniet repellat facilis consectetur veritatis deleniti explicabo ducimus! Debitis numquam unde necessitatibus esse sed. Earum accusamus itaque autem reiciendis aliquam laboriosam sint rem illo explicabo culpa?</p>
</div>

Answer №3

Don't forget to include 'px' in the media query. Try using 800px and it should work fine.

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

Navigating the ropes of push-pull functionality in Bootstrap 5

How can I utilize push and pull in Bootstrap version 5.0.0-beta2? In Bootstrap 3, my code looks like this: <link href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" rel="stylesheet" /> <div class="row"> <d ...

Rejuvenating your HTML content with AJAX over time

My HTML page contains links to charts that refresh every time the page is reloaded. A friend mentioned that AJAX can automatically refresh the chart at specified intervals without reloading the entire HTML page. I would appreciate any help with the HTML ...

Select all feature in checkbox is malfunctioning

I need to implement a feature with 3 checkboxes: When the "A" checkbox is clicked, only "A" should be highlighted. Upon clicking the "C" checkbox, only "C" gets highlighted. If the "B" checkbox is clicked, both "A" and "B" nee ...

Trigger a change event for a Material Checkbox by referencing its unique identifier

<div *ngFor="let cus of deselectedList | keyvalue" (click)="clickCheckBox('customer_'+cus.key+'_checkbox')"> {{cus.key}} <mat-checkbox id="customer_{{cus.key}}_checkbox" (change ...

Modifying the calendar from a 7-day week to a 5-day week

I am currently in the process of developing a 7-day calendar (Sunday to Saturday) which is functioning well. However, I am interested in adding an option to switch it to a 5-day calendar (Monday to Friday). I was wondering if there is a way to modify the e ...

View the selected radio buttons and checkboxes next to each other in real-time before finalizing and submitting

Within my form, individuals have the option to select from radio buttons and checkboxes. The challenge is that I need to display the chosen data on the page before they enter their email and submit! Since I cannot refresh the page, PHP won't work for ...

Hide the HTML DIV without altering the position of the current div

My goal is to conceal elements 1, 3 and 2 & 4 without changing their position. div{ width: 10%; float: left; } <div style="background-color: blue"><p>1</p></div> <div style="background-color: yellow"><p>2</ ...

How can I ensure that I am only retrieving the first object within a "for loop" in vuejs and returning its value without getting the rest?

Why am I only able to retrieve the value of the first object in my "for loop" and not all three values as intended? var app = new Vue({ el: '#app', data: { myObj: [ {name: 'Hello', age: 10}, {name: ...

Comprehending the positioning of elements enclosed within a parent <div> tag

I'm struggling to understand why: vertical-align - isn't behaving as expected in this scenario, even though the elements are aligned along a baseline and are inline elements. I've experimented without using float but that didn't sol ...

Activate the button with a tap of the space bar on a webpage

Is it possible to have a button on a webpage triggered both by clicking with the mouse and hitting the spacebar? HTML <div class="col-12 button small-button"> <a onclick="generator()"> <img src="icones%20web%20projeto.p ...

What strategies can I use to ensure that the navigation bar is responsive when viewed on a

Check out my CSS file here for the navigation styling. See the screenshot of my HTML file showcasing the navigation panel here. I'm seeking assistance in making my navigation responsive on all mobile devices, as it is currently not functioning prope ...

The enchanting world of CSS background scrolling animations

I am currently developing a website where I have split the hero/header into two sections - one on the left with information and the other on the right with a graphic. I wanted to add a simple parallax effect to the image on the right side, so I used backgr ...

How can I make my navbar visible once a specific section has been reached?

Is there a way to conditionally display my navbar in react only when a specific section is reached? Currently, I am monitoring scroll position but this method becomes unreliable on larger screens due to varying scroll positions. I need the navbar to beco ...

Incorporate an additional javascript document into a VueJS component

What is the most efficient method to include Javascript files in Vue.js components? ...

Form-select failing to transmit data

There seems to be an issue with one specific HTML field not sending data. This is my HTML code: <form id="login_registro_form" role="form" method="post" action="./controllers/register.php"> <div cl ...

GAE does not have access to background images

Having trouble loading background pictures in my GAE front-end app. "Failed to load resource: the server responded with a status of 404 (Not Found)". My app is a simple website, no GAE backend. Using Eclipse with Google AppEngine Plugin. Background pict ...

"Utilizing Material UI's Stack component for a responsive, full-width

Is there a way to achieve full width for Item 2 without using width:100% with flexbox? <Box sx={{ width: '100%' }}> <Stack spacing={2} alignItems="flex-start"> <Item>Item 1</Item> <Item>Item 2< ...

Zooming on a webpage is causing problems

One issue I'm facing is with the elements on my page acting strange when I zoom in and out. Everything seems to be working fine except for a container div that should overlay a color over the image background. When I zoom in or switch to mobile view, ...

Updating the progress bar without the need to refresh the entire page is

Currently, I have two PHP pages: page.php and loader.php. Loader.php retrieves data from MySQL to populate a progress bar, while page.php contains a function that refreshes loader.php every second. This setup gets the job done, but it's not visually a ...

Updating style of element in EJS following POST request in Node.js using Express

I am working on a form page that is supposed to display a Success Alert (Boostrap) once the user fills out the form and clicks the Submit button. <form class="well form-horizontal" action="/contact" method="post" id="contact_form"> ... (input fiel ...