Tips for folding the center div downwards

In the code snippet below, there are three divs that should respond to window resizing by adjusting their layout.

When the window becomes too small, the middle div should move down as illustrated in the accompanying image.

<!DOCTYPE html>
<html>
<head>
    <style>
        #mainCont
        {
            background-color: lightblue;
            display: flex;
            justify-content: space-between;
        }#middleCont
        {
            background-color: lavender;
        }#middleCont a
        {
            padding: 0 80px;
        }
    </style>
</head>
<body>
    <div id="mainCont">
        <div>Word</div>
        <div id="middleCont">
            <a href="#">link 1</a>
            <a href="#">link 2</a>
            <a href="#">link 3</a>
            <a href="#">link 4</a>
            <a href="#">link 5</a>
        </div>
        <div>Word</div>
    </div>
</body>
</html>

(https://i.sstatic.net/VN02X.jpg)

Many thanks for your assistance.

I am looking forward to achieving the desired layout shown in the image.

Answer №1

By utilizing the order css property, we have the ability to rearrange elements based on screen size and apply flex-wrap to create an additional row Link to Documentation

It is highly recommended to use class name selectors rather than id selectors

.mainCont
        {
            background-color: lightblue;
            display: flex;
            justify-content: space-between;
        }
        .middleCont
        {
            background-color: lavender;
        }
        .middleCont a
        {
            padding: 0 80px;
        }

@media (max-width: 575.98px){
  .mainCont{
    flex-wrap:wrap;
  }
  .middleCont{
    order:3
  }
}
<div class="mainCont">
        <div>Word</div>
        <div class="middleCont">
            <a href="#">link 1</a>
            <a href="#">link 2</a>
            <a href="#">link 3</a>
            <a href="#">link 4</a>
            <a href="#">link 5</a>
        </div>
        <div>Word</div>
    </div>

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

How to avoid clipping in Bootstrap 4 when a row overflows with horizontal scrolling

In order to allow for horizontal scrolling of all contained columns, I created a row using the row class. To implement this feature, I followed advice from a contributor on Stack Overflow. You can view their answer by following this link: Bootstrap 4 hori ...

Exploring the art of beautifying React.js with SCSS

I have been working on creating the homepage layout for a project using SCSS to style Reactjs with the assistance of an online course. However, I am facing an issue where my layout looks different from the one presented in the course even though I have app ...

Unveil the path as you scroll

Currently, I am tasked with creating a dynamic timeline that has animations triggered by scrolling. As part of this project, I must also reveal a pathway as the user scrolls - this pathway consists of circular shapes. The challenge lies in revealing an im ...

Tips for accurately aligning a relative p tag within a td

Description: I am trying to prevent text overflow in a table cell and position the text underneath a header without wrapping it under an image. I have tried setting a static width for the image and adjusting the left property, but it is not working as expe ...

Expanding the table area in bootstrap

I am currently working on a video slider using bootstrap. I have added a table within the slider (carousel) and it is functioning perfectly. However, I am now looking to update the layout to resemble the image below. I have successfully applied the backgro ...

Embedding CSS directly into PHP output

I have a table where I want to include a vertical-align property: $output = '<style type="text/css">div.bar-container {border: 1px solid #ccc; width: 150px; margin: 2px 5px 2px 17px; padding: 3px; float: left; background: white; position:relati ...

Issues concerning the customization of error messages in forms are arising

Summing it up, upon form submission, error messages appear beneath each input field with invalid values. Utilizing Zend_Form results in the following markup: <form enctype="application/x-www-form-urlencoded" method="post" action="/auth/register">< ...

Center align a row with the help of Bootstrap 4.0

Here is some code with Bootstrap 4 classes that I am working with: <div class="container"> <div class="row"> <div class="col-xl-4 col-md-6 col-lg-4"> <div class="footer_widget"> <h3 class ...

Overlay with a progress bar that obscures visibility

I'm dealing with a progress bar that needs to be displayed on top of an overlay. If you take a look at this jsfiddle, you can see the issue. Here's the markup: <div class="overlay mouse-events-off"> <div class="progress progress-st ...

Using jQuery and CSS to change to "loading" status

My current setup includes the following: <div class="click red"></div> <div class="click green"></div> <div class="click blue"></div> When the "click" is clicked, I want to add the class "load" to the div. I have succe ...

li tag style

I need to insert a check mark inside the <li> tag on the right side. How can I do this? The check mark looks like this: For example: http://jsfiddle.net/HpVcy/ ul li{ padding: 3px 10px 3px 10px; background:url(http://img4up.com/up2/730897458613759 ...

Issues with loading SASS or source maps arise when dealing with nested structures

After reorganizing my SASS files into a nested structure, I encountered an issue where inspecting elements in Chrome led me to incorrect source maps. For instance, when trying to inspect a button, instead of being directed to the _buttons partial as expect ...

Adjust the header's alignment to seamlessly coincide with the uppermost part of the

I'm encountering this peculiar issue with a website I recently started designing. My aim is to make the header perfectly aligned with the top of the page. However, despite my attempts, there persists a stubborn gap that measures around 20px, defying a ...

Tips for displaying a Bootstrap 4 table on smaller screens

I have a Bootstrap 4 table filled with JSON data. The table renders perfectly on the UI, but users on smaller devices must scroll to view all the data. Despite there not being much data in the HTML table, users still need to scroll on small devices. I wa ...

Creating the necessary user interface using JSON data.Here are some steps to follow

I am struggling to create a dynamic UI based on JSON data. The issue I'm facing is with looping through the data to generate the required elements. My Goal: Achieving a Dynamic UI from Static Code .switch { position: relative; display: inline- ...

What is the best way to place an anchor tag with an image inside a bootstrap grid cell?

I am facing an issue with a 9-cell grid that contains images using Bootstrap columns. The grid is responsive and functions perfectly when only images are present. However, I want to make the images clickable by placing them inside anchor tags (<a>). ...

Positioning a bootstrap badge flawlessly inside a block of text

The issue arises when adding a badge in the image below, as there seems to be more space above the badge than below it. Even though the Bootstrap 4 code is clean and untouched, it doesn't work seamlessly. Despite my attempts to adjust margins and line ...

Ruby on Rails slider bar functionality

Currently, I am developing a video-focused application using Ruby 1.9.2 and Rails 3.1. One of the key features I need to implement is a slider bar that allows users to adjust the total duration of a video in real-time. Despite my attempts to use HTML5 fo ...

implementing a properly aligned nested button group with Bootstrap 4 framework

My button group control looks like this. <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.8.2/css/all.min.css" rel="stylesheet"/> <link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css" ...

Tips for arranging divs in CSS grid with grid-template-areas technique

I am attempting to organize similar groups of elements in a grid: #grid { position: absolute; left: 135px; top: 158px; width: 1080px; height: 1035px; display: grid; grid-template-rows: 99px 1fr 1fr; grid-template-column ...