Utilizing CSS Media Queries for Page Layout Adaptation

After previously asking about a different issue with this project, I have encountered yet another problem.

The task at hand requires using three distinct media queries to alter the page layout depending on the screen size in use (currently being tested by adjusting my browser window). These three queries are expected to function as follows:


Screen Size <400:
Background 1
Vertical bulleted lists.
Bulleted lists positioned below the two columns.
The Road to Enlightenment section above the Make it Good section.

Screen Size >=400 and <500:
Background 2
Horizontal bulleted lists.
Bulleted lists placed to the right of the two columns.
The Road to Enlightenment sections situated to the left of the Make it Good section.

Screen Size <500:
Similar to the previous query but with background 3.

Everything appears to be working correctly except for getting the columns to display side-by-side once the size reaches 400. By that, I mean when resizing the window, the background changes properly, everything seems fine, except the columns fail to align side-by-side until the screen is halfway between its narrowest point and maximized (I hope that clarifies the issue).

Below is my CSS code:

@media (max-width: 399px) {
    //CSS for Screen <400
}

@media (max-width: 499px) and (min-width: 400px) {
    //CSS for Screen >=400 and <500
}

@media (min-width: 500px) {
    //CSS for Screen >=500
}

Although the project instructions don't allow modifications to the HTML, only CSS adjustments, any recommendations on resolving this column alignment issue would be greatly valued.

Answer №1

To implement this, use the column-count and column-gap css properties within a specified class like so:

.wrapper {
  column-count: 3;
  column-gap: 10px;
}

By applying these styles to elements with the class .wrapper, your content will automatically be displayed in three separate columns with a 10px gap between each one.

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

When I implement the persist gate in Next.js with Redux, the flex direction automatically adjusts

I'm currently developing an app using next js and redux. An interesting issue has arisen - when I include PersistGate in my _app.js file, the flex direction mysteriously changes from row to column in index.js. There haven't been any modifications ...

"Managing output buffers, styling with CSS, and sending emails with PHP

I am currently using a script to send emails that result in a couple of HTML tables: $from = "example.com <<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="82efebe7ef83898ce0ede1e9e3e6d2edeee8">[email protected]</a ...

Switching Font Family Option for Selection Mat in Angular Material

I'm currently working on changing the font of the options inside mat-select ("In what city were you born", etc). After some experimentation, I found that by setting ViewEncapsulation to none (allowing styles from other files to bleed in), I am able t ...

Floating container leads to delays

My goal is to create a div that changes when I hover over it. However, when I move my mouse into the div, there seems to be some lagging and the content does not appear clearly. Below is the HTML and CSS code I have used: .unshow-txt:hover, .unshow-txt: ...

Design a visually stunning image grid with the use of Bootstrap 4

I am having difficulty creating an image grid with consistent spacing between columns, like shown in the image below: https://i.sstatic.net/azsxa.jpg The issue I am facing is aligning the right margin (red line), as illustrated below: https://i.sstatic. ...

Looping through mysql data horizontally within a div tag

Looking for assistance to create a content loop similar to the one on this website? I attempted to use a while() loop, but it ended up displaying vertically without using a table. I suspect this page utilizes thumbnails. What I aim for is to have the it ...

Is it possible to utilize a hyphen in the link_to attribute?

I'm encountering a dilemma in my Rails app where I need to assign a value to a custom data-* attribute for an anchor tag. The issue is that hashes can't contain hyphens, leading to difficulties with this code: <%= link_to 'Example', ...

What is the best way to develop an expanding line animation from this starting point?

I have a vision for an animation where, upon hovering over an icon, it enlarges, increases in opacity, and reveals some accompanying text. The visual effect I am aiming for involves two lines of color expanding horizontally from the center outwards before ...

Users are directed to various pages based on their specific roles

I am currently working on implementing a simple authorization system using an array to simulate a database. Let's say I have an array with information about two individuals: const users = [{ info: 'First person', login: &apos ...

concealing the date selection feature on the data picker

$('.year').datepicker({ changeMonth: true, changeYear: true, showButtonPanel: true, dateFormat: 'MM yy', onOpen: function(dateText, inst) { $("table.ui-datepicker-calendar").addClass('hide') }, onClos ...

Exploring the features of AngularJS with a secure login page

I need some guidance on the best way to create a login page. Currently, I have set up a ng-view root ("/login") in my app.js file. The issue I am facing with this approach is that I have to include static HTML in other files using ng-include. (This stati ...

Advanced data synchronization with Angular 7's bidirectional data binding feature

One input box allows users to enter a number, and I would like to adjust the width of the background color based on that number. The box itself will have a fixed width, but I am looking to dynamically change the width of the background color according to ...

Concealing a section of a table with JavaScript while preserving the original table structure

I made some adjustments to the script tag: $(document).ready(function) { Now, the evenTd's are hidden correctly. Here is the table with the code provided: <table> <tr> <td>itemOne</td> <td class="even ...

Utilizing a function within a loop that is nested within another loop

//Exercise 3a: for (var a=1; a<12; a++) { for (var b=00; b<60; b++) { for (var c=00; c<60; c++) { console.log(a + ':' + b + ':' + c + 'AM'); } } } for (var alpha=12; alpha<13; al ...

PHP search function malfunctioning

I'm feeling quite confused about the current situation. I am utilizing a form that requires a student code input of "lz." <form action="classgrades.php?id=<?php echo $courseid ?>" method="post"> <input type="text" name="studen ...

When I click on the md-select element, a superfluous "overflow-y: scroll;" gets added to the <body> of my webpage

Typically, I have the following styles on my body: element.style { -webkit-app-region: drag; } However, when I interact with a md-select element (you can observe this behavior on the provided link), additional styles are applied. element.style { -w ...

Generating grid-style buttons dynamically using jQuery Mobile

I am in need of assistance to create a dynamic grid using jQuery Mobile. The grid should consist of buttons with either 'onclick' or 'href' functionality. The number of buttons should be generated dynamically at runtime. Specifically, I ...

Tips for aligning text to the right and keeping it in line with another section

I have a code snippet and I'm aiming to align the caption for my "DigDug" game directly below the game itself, perfectly lined up horizontally. The id for the caption is "#DigCaption" and the id for the game is "#DigDug". Could anyone provide guidance ...

Can you provide guidance on how to successfully transfer an array of JSON objects from the script section of an HTML file to the JavaScript

My webpage contains an array of JSON objects that I need to send to the server. The array, stored in a variable called results, appears normal when checked in the console before trying to POST it. Here is a sample of the data: 0: {id: 02934, uName: "Ben", ...

Showing a picture in Angular from a stored image on a node.js server

I'm curious about security measures. Let's say I've uploaded an image of an animal to the server, such as 1545419953137bear.jpg, which is stored in my backend uploads folder along with other images. On the frontend, I use an img element wit ...