Support » Fixing WordPress » Reordering of elements

  • peter0013

    (@peter0013)


    Hi!
    I’m trying to figure out how to change the order of elements in mobile view. I have a site with a contact sidebar to the right of images and description, and below description of in this case different apartments. In mobile view though, the contact form comes above the description of the apartments, but I would like it to come below the description on mobile.

    I have like two elements called col-md-3 verticalagent and col-md-9 rightmargin full_width_prop. On desktop the first one is placed at right besides images of the apartment, like a sidebar, and the second is placed below the images. But on mobile the first is placed before the description. I would like to change order of them on mobile.
    I have tried diverse CSS codes, but don’t succeed.
    See these images

    https://drive.google.com/file/d/1Y_IG1KRwWCHDEifZHLdVHag6fmYexl_0/view?usp=sharing

    https://drive.google.com/file/d/1seJh_bXmfxExM3EhmzbUmVoTjJnOxpdY/view?usp=sharing

    Regards Peter

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Artemio Morales

    (@artemiosans)

    Hello!

    The best solution I’ve found in situations like this is to simply duplicate the sidebar and use two versions of it in the HTML, one for desktop and the other for mobile:

    -You could leave the first version where it currently is, and make that visible only on desktop, but hide it on mobile.

    -For the second version, you could place it so that it appears correctly after the description, and hide it on desktop, but make it visible in mobile.

    If you are able to modify the CSS, you can target each version of the HTML accordingly using media queries:

    
    .desktop-sidebar {
       display:  block;
    }
    .mobile-sidebar {
       display:  none;
    }
    
    @media (max-width: 700px) {
       .desktop-sidebar {
          display:  none;
       }
       .mobile-sidebar {
          display:  block;
       }
    }
    
    Thread Starter peter0013

    (@peter0013)

    Is doesn’t work in the theme I have.
    Couldn’t something with #order work? I mean to change the order of the elements on smaller screens?
    I have tried different CSS with this, but can’t make it work.

    Peter

    Artemio Morales

    (@artemiosans)

    For the order property to work, the elements in question need to be siblings in a container with the display: flex or display: grid, which means you would need to restructure the HTML to achieve that.

    Here’s an example of the order property in action.

    HTML

    <div class="container">
        <div class="first-element">
            <h1>First Element</h1>
        </div>
        <div class="second-element">
            <h1>Second Element</h1>
        </div>
    </div>

    CSS

    .container {
        display:  flex;
    }
    
    .first-element {
        order:  0;
    }
    
    .second-element {
        order:  1;
    }
    
    @media (max-width: 700px) {
        .first-element {
            order:  1;
        }
    
        .second-element {
            order:  0;
        }
    }
    • This reply was modified 1 year ago by Artemio Morales. Reason: Code was not formatted properly
    • This reply was modified 1 year ago by Artemio Morales.
    Thread Starter peter0013

    (@peter0013)

    Thanks!

    Peter

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Reordering of elements’ is closed to new replies.