Is it possible to manipulate divs with CSS media queries for positioning?

I currently have a footer displayed on the desktop version of my website, which appears like this:

https://i.sstatic.net/ZMUZj.png

However, for tablets (with a width less than or equal to 960px), I need to adjust the layout using media queries to look like this:

https://i.sstatic.net/G01oI.png

The challenge lies in arranging the divs without resorting to using empty ones.

Here is the code snippet for the desktop version:

jsx:

<footer>
    <div className="footer-content">
        <div className="col">1</div>
        <div className="col">2</div>
        <div className="col">3</div>
        <div className="col">4</div>
        <div className="col">5</div>
    </div>
    <div className="another-stuff">
        another stuff
    </div>
</footer>

and css:

.footer-content {
  display: flex;
  justify-content: space-between;
  margin-bottom: 7%;
}

.col {
  display: flex;
  flex-direction: column;
}

Attempted to implement:

.footer-content{
    display: flex;
    flex-wrap: wrap;
  }

  .footer-content .col {
    flex: 1 0 33%;
  }

Yet, elements 4 and 5 ended up misplaced in the center of the page.

Answer №1

To achieve the desired layout, apply the CSS flex attribute set to "nowrap".

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

Automatically forward after submitting the form

I am utilizing the Mingle plugin on my Wordpress website to allow users to register and post on a dedicated Mingle Forum. Although the signup process is functioning correctly, I wish to enhance user experience by redirecting them to the forum page after t ...

How can we create a two-dimensional image with random dimensions using Math.random?

I am struggling to create a variety of flowers with different sizes from an Array. The issue I'm facing is that every time I click to add a new flower, it changes the size of all existing flowers as well. What I would like is for each added flower to ...

The RadioGroup does not reflect the choice made by the user in the selected radio button

I am working on creating a dynamic Radio Group using Material UI, where the radio buttons are built based on an object parameter. Everything seems to be functioning correctly as the state changes when clicking on the radio button. However, I am facing an i ...

Harnessing the power of external Javascript functions within an Angular 2 template

Within the component, I have a template containing 4 div tags. The goal is to use a JavaScript function named changeValue() to update the content of the first div from 1 to Yes!. Since I am new to TypeScript and Angular 2, I am unsure how to establish comm ...

Error encountered in Typescript React: JSON API Object expecting a ":" when indexing

Using Axios in Typescript React to fetch API Data. Here is a glimpse of the JSON Data :https://i.sstatic.net/DCXTz.png Trying to access the number value at index 1.tokenAmount.uiAmount Currently attempting data?[1]["tokenAmount"]["uiAmount"], but encoun ...

Adding Angular directives to the DOM after the document has finished loading does not function properly in conjunction with ngAnimate

I've been working on developing an Angular service that can dynamically append a notification box to the DOM and display it without the need to manually add HTML code or write show/hide logic. This service, named $notify, can be used as follows: $no ...

Tips for applying multiple style properties to an element using JavaScript

I have been experimenting with different versions of this code in an attempt to modify a specific element for a coding challenge, but none of them seem to successfully change multiple styling properties of the element upon clicking on a button. Would great ...

How can I prevent an outside click event from triggering if it occurs on the button? (Using Vue 3)

Seeking assistance from anyone who can help me out. I have a popup and a button, and when I click the button, the popup window should open. Additionally, when I click outside the popup or on the button, the popup should hide. https://i.sstatic.net/vDZ7L.p ...

What is the best way to use PHP strip_tags to filter out HTML and Script tags while keeping XML untouched?

I have been using the strip_tags() function in PHP to get rid of HTML tags from my text area input and to eliminate < script > tags for security reasons. However, I have run into an issue where the function ends up removing benign XML tags that are ...

Is it possible to skip backend validation when using the "please confirm by typing" delete pattern?

What are your thoughts on a specific situation involving frontend and backend validation? The consensus online is that both frontend and backend validation should be present for REST APIs. In my case, I am developing a modal that asks the user to input th ...

Issue with enabling overflow-y: scroll within a Bootstrap Modal

I've implemented a modal using the Bootstrap library that contains multiple lists populated through Ajax search requests. These lists have a fixed size and utilize the CSS property overflow-y: scroll to accommodate a large number of elements without a ...

Having difficulty navigating the website due to the inability to scroll

I am experiencing a problem on this website where I am unable to scroll. Visit www.Batan.io After loading the website for the first time, the trackpad (mac) works fine initially but then the scroll function stops working. Although the sidebar works, chan ...

Should PHP be avoided in CSS files?

I've recently developed a CSS page named style.php and at the beginning, I included this line: <?php header("Content-type: text/css"); ?> What are your thoughts on this approach? Is it considered a bad idea? The reason behind doing this is tha ...

Utilizing NextJS to retrieve cookie data within React components

Currently, I am working with a Next.js frontend and an Express backend. For authentication, I am utilizing cookies and have set up protected routes using Next.js middleware. The next step in my project involves accessing the cookie response within React ...

Having trouble installing Material UI on React 18?

I'm facing an issue while trying to integrate Material UI and icons into my React 18.0 project. The project was built using the latest create-react-app. npm install @material-ui/core @material-ui/icons npm ERR! code ERESOLVE npm ERR! ERESOLVE unable ...

What are some ways to display unprocessed image data on a website using JavaScript?

I have an API endpoint that provides image files in raw data format. How can I display this image data on a website using the img tag or CSS background-image property, without utilizing canvas? One possible approach is shown below: $.get({ url: '/ ...

Overlapping borders create a unique style for bootstrap labels

Below is a snippet of code with div elements that each have a 1px border defined in the labelStyle class. .labelStyle { text-align: left; padding: 0px; font-weight: 0px; font-size: 8px; border: 1px solid; margin-bottom: 0; bor ...

I am currently encountering an issue when attempting to run my React project using Yarn. What steps should I take to resolve this error?

As I attempt to launch my React project using YARN, an error is thrown stating that react-scripts.js already exists in the file. What steps should I take to address this issue? Click here for an image of the error ...

Safari is truncating the box-shadow of an element enclosed within a button

I'm struggling with a button that has an element inside receiving a box-shadow: button { padding: 0; border: 0; margin: 0; overflow: visible; -webkit-appearance: none; background: white; } .shadow { display: inline-block; vertical- ...

I'm receiving an ENOENT error when trying to run npm start. Can someone explain why this error is occurring and why it seems to be searching for the "My Pictures

Currently, I am integrating MUI's Data Grid component into my React project. After successfully installing the package using $npm i @mui/x-data-grid, I faced an unexpected ENOENT error upon importing DataGrid and running $npm start. Can anyone shed li ...