I implemented the order property in the css, however the layout positions remain unchanged

<section id="home">
 <div class="container">
  <div class="row align-items-center container-items">
    <div class="col-md-6">
      <div class="info">
        <h1>Lorem ipsum dolor sit amet <u style="color: rgb(165, 177, 231);">consectetur.</u> </h1>
        <p>Lorem ipsum, dolor sit amet consectetur adipisicing elit. Fuga, pariatur corporis! Quaerat officiis sit rerum exercitationem 
          facilis quas ex veritatis quod dolores delectus reiciendis autem dignissimos doloremque consequuntur, ad eaque possimus corrupti. 
          Fugiat, non unde labore, cupiditate nobis quis maxime error, omnis rerum tenetur officiis ea doloremque qui nihil officia?</p>
      </div>
      <ul>
        <li>
          <img src="./image/freshfood.png" alt="">
          <span><u>Fresh Foods</u> </span>
        </li>
        <li>
          <img src="./image/restaurant.png" alt="">
          <span> <u>Master Chefs</u> </span>
        </li>
      </ul>
    </div>
    <div class="col-md-6 food-img">
      <div>
        <img src="image/home.png" alt="">
      </div>
    </div>
  </div>
 </div>
</section>

To ensure that the elements within the HTML code reorder correctly at a screen width below 575.98 pixels, I have utilized CSS flex properties for the specific classes. By applying 'order' property to .info and .food-img classes, I can control the visual placement of these elements when viewed on smaller devices.

  #home .container-items  {
    display: flex;
}
#home .info{
    max-width: 100%;
    height: 15rem;
    order: 1 ;
  }
  #home .food-img{
    order: 2;
}

I have included the above CSS styles in order to adjust the positioning of different sections as per the screen size. Typically, defining the 'order' property is essential to rearrange the layout and prioritize certain content depending on the available space. This implementation ensures a responsive design by dynamically switching the display order of elements under specified conditions.

Answer №1

Paulie_D makes a valid point, noting that this method is effective only on the direct children with the classes flex-item-1 and flex-item-2 in the code snippet below. You can then set the order for these child elements:

#home .container-items {
  display: flex;
}
#home .info {
  max-width: 100%;
  height: 15rem;
}

@media only screen and (max-width: 575.98px) {
  .container-items {
    flex-direction: column;
  }

  .flex-item-1 {
    order: 2;
  }

  .flex-item-2 {
    order: 1;
  }
}
    <section id="home">
      <div class="container">
        <div class="row align-items-center container-items">
          <div class="col-md-6 flex-item-1">
            <div class="info">
              <h1>
                Lorem ipsum dolor sit amet
                <u style="color: rgb(165, 177, 231)">consectetur.</u>
              </h1>
              <p>
                Lorem ipsum, dolor sit amet consectetur adipisicing elit. Fuga,
                pariatur corporis! Quaerat officiis sit rerum exercitationem
                facilis quas ex veritatis quod dolores delectus reiciendis autem
                dignissimos doloremque consequuntur, ad eaque possimus corrupti.
                Fugiat, non unde labore, cupiditate nobis quis maxime error,
                omnis rerum tenetur officiis ea doloremque qui nihil officia?
              </p>
            </div>
            <ul>
              <li>
                <img src="https://picsum.photos/60" alt="" />
                <span><u>Fresh Foods</u> </span>
              </li>
              <li>
                <img src="https://picsum.photos/60" alt="" />
                <span> <u>Master Chefs</u> </span>
              </li>
            </ul>
          </div>
          <div class="col-md-6 food-img flex-item-2">
            <div>
              <img src="https://picsum.photos/300/200" alt="" />
            </div>
          </div>
        </div>
      </div>
    </section>

In such cases, you could simply utilize flex-direction: column-reverse;:

#home .container-items {
  display: flex;
}
#home .info {
  max-width: 100%;
  height: 15rem;
}

@media only screen and (max-width: 575.98px) {
  .container-items {
    flex-direction: column-reverse;
  }
}
    <section id="home">
      <div class="container">
        <div class="row align-items-center container-items">
          <div class="col-md-6 flex-item-1">
            <div class="info">
              <h1>
                Lorem ipsum dolor sit amet
                <u style="color: rgb(165, 177, 231)">consectetur.</u>
              </h1>
              <p>
                Lorem ipsum, dolor sit amet consectetur adipisicing elit. Fuga,
                pariatur corporis! Quaerat officiis sit rerum exercitationem
                facilis quas ex veritatis quod dolores delectus reiciendis autem
                dignissimos doloremque consequuntur, ad eaque possimus corrupti.
                Fugiat, non unde labore, cupiditate nobis quis maxime error,
                omnis rerum tenetur officiis ea doloremque qui nihil officia?
              </p>
            </div>
            <ul>
              <li>
                <img src="https://picsum.photos/60" alt="" />
                <span><u>Fresh Foods</u> </span>
              </li>
              <li>
                <img src="https://picsum.photos/60" alt="" />
                <span> <u>Master Chefs</u> </span>
              </li>
            </ul>
          </div>
          <div class="col-md-6 food-img flex-item-2">
            <div>
              <img src="https://picsum.photos/300/200" alt="" />
            </div>
          </div>
        </div>
      </div>
    </section>

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

ng-model causing simultaneous changes to all selects

Check out this jsfiddle link Hello there, I'm encountering an issue with my application. I need to create multiple dropdowns using ng-repeat and have them all populated with the same options. The problem arises when one dropdown is changed, all ot ...

Tips for enhancing the "Eliminate render-blocking resources" score on the Lighthouse report for Progressive Web App (PWA) optimization

Check out my first attempt at a PWA here: My goal is to achieve a perfect 100% in Lighthouse for all categories :) https://i.sstatic.net/9Ql9r.png Although I've read the "Learn More" page, I'm still struggling with how to implement Bootstrap C ...

Trouble with the visibility and functionality of the Bootstrap navbar collapse icon

I'm currently working on a project where I want to incorporate a collapsible navbar. The issue I'm facing is that when I resize the window, the navbar collapses but the button, although clickable, does not display or provide me with any options. ...

Identify when a browser tab is closed and determine which specific tab out of all the open tabs was closed

Is there a way to identify when a browser or tab is closed in Angular/JavaScript? I would like to know if there are specific events that can be used for detecting these actions. Any advice, information, or code examples on this topic would be greatly app ...

Struggles with implementing CSS Grid's dynamic column heights and expanding rows

Linked partially to Removing empty space in CSS Grid, with specific adjustments I am aiming for. Essentially, I want my rows and columns to expand and contract based on the content present. In this CodePen example, you can observe that the content of the ...

Manipulating SVG on a UIWebview dynamically

Seeking guidance on manipulating SVG files loaded into a UIWebview. Currently, I load an SVG file into an HTML file and then into a UIWebview. Presumably, Javascript is required for this, but unsure about the exact process. Ideally, I aim to dynamically ma ...

What is the process for integrating vue-select into the dialog of JqxScheduler?

If you want to customize the JqxScheduler's edit dialog, you can modify the existing containers in the editDialogCreate method. Here is an example: var titleSelector = $(` <div> <div class='jqx-scheduler-edit-dialog-label' ...

Achieving Proper Alignment of Dropdown Menu in CSS

Currently, I am tackling the challenge of creating a responsive navigation bar. Despite my numerous attempts to troubleshoot, I am struggling to find a solution. My current issues are as follows: 1) On wide screens, I aim to center the dropdown menu benea ...

The issue with material-ui 0.15.2 is that it applies extra vendor-prefixed styles on the server side but not on the client side, resulting in warnings in React 15

I have set up my project with the following configurations: react is at version 15.2.1 material-ui is at version 0.15.2 I am using express and universal-router for server-side rendering Every time I include a material-ui component, I encounter this erro ...

How can you reset the chosen option in a Vue.js dropdown menu?

Within my dropdown menu, I have included a button that is intended to clear the selected city. Despite adding an event, the selected option is not being cleared. Can anyone provide insights on what I might be missing? Thank you in advance. Below is the bu ...

Height of list items in image gallery does not automatically readjust

I'm facing an issue regarding the height of an li element. Check out this CodePen link for reference. <div class="row fp-gallery"> <ul class="large-block-grid-4 medium-block-grid-4 small-block-grid-2"> <li> <a href= ...

What is the best method for users to add a div element and its contents?

As someone new to the world of web development, I am currently learning and working on a project. I have encountered an issue with creating a custom div that includes a link and user-defined text. I want the div to be generated automatically when the use ...

Exploring the differences between SASS and Bootstrap: the battle of mixins versus @extend

Currently utilizing the SASS version of Bootstrap found here. Curious as to whether there are distinctions between using the pre-set mixins versus utilizing SASS's @extend. For example, considering the following: <div class="wrapper"> Some ...

Is there a way to create a hyperlink that automatically opens in a new page with just HTML?

Although this may be a simple request, I would greatly appreciate your assistance with my computer science project. Thank you in advance! ...

What is the process of utilizing PHP to validate form input within an HTML file?

I need to implement a dropdown menu item for signing in, but I am unsure how to validate the form input. Currently, I have separate pages for signing up and logging in with PHP scripts handling the validation and redirection. The issue is that I want user ...

Experience the ultimate in slider automation with the cutting-edge power of

Here is an example of a website plugin I used on my site. You can check it out by clicking here. However, I'm having trouble automating the events that occur when the item slider is clicked. I would like to make these events happen automatically with ...

Is it possible to dynamically alter the text and contrast of your entire website?

In the realm of MVC 4 and Visual Studio 2013: I am pondering over how to dynamically change the text on my website with the simple click of a button. The same goes for adjusting contrast. Are there any plugins or techniques that could facilitate this proc ...

Successfully bypassed Captcha by using inspect element

Currently, I have integrated Google Captcha on my login page. However, upon inspecting the elements, I noticed that the Captcha element is visible in the source code. This allows me to delete the element, essentially removing the Captcha checkbox and byp ...

Display all elements on a webpage using Javascript without the need for scrolling

I'm looking for a way to ensure all items on a webpage load immediately, without having to scroll down multiple times before running a script to find a specific item. Is there a method to have all items load at once without the need to manually scroll ...

Using Javascript, display an image that was previously hidden with CSS when a radio button is selected

Within a table of 25 rows, each row contains an attribute accompanied by an image (represented by a tick symbol) and five radio buttons for rating the attribute from 1 to 5. Upon clicking one of the radio buttons, the hidden image (tick symbol) should beco ...