Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Nambinina 2 posts 72 karma points
    1 week ago
    Nambinina
    0

    Umbraco Grid

    hello, I'd like to modify my grid layout for mobile display by always prioritising Images. I've already tried using ‘Order’ in CSS but it doesn't work.

    eg:

    image1

    Text1

    Text2

    image2

    Normally it is displayed like:

    image1 text1 text2 image2

    and on mobile, it should always be displayed in the order : -image1 -text1 -image2 -text2

  • npack 46 posts 292 karma points
    1 week ago
    npack
    0

    What I use is a CSS grid feature called grid areas.

    For example, if I want two columns, one for text and one for an image. On desktop I want my text on the left side, but for mobile I want the image on top:

    In your markup, give each column an appropriate class name

    <div class="my-grid">
        <div class="text-column">Text</div>
        <div class="image-column">Image</div>
    </div>
    

    Then in your css you assign those column's classes to a grid area. I use the same grid-area name as my class just to avoid confusing myself but the names don't need to be the same

    .text-column{
        grid-area: text-column;
    }
    .image-column{
        grid-area: image-column;
    }
    

    Then where you set up your grid, you reference these areas,using the "grid-template-areas" feature -- in the order you want them to appear. So since in my case my mobile layout is the default I do it with the image column first.

    .my-grid{
        display: grid;
        grid-template-areas: 'image-column' 'text-column';
        grid-template-columns: 1fr;
    }
    

    Then for my desktop display override, I swap the column order

    @media (min-width: 768px) {
        .my-grid{
            grid-template-areas: 'text-column' 'text-column' ;
            grid-template-columns: 1fr 1fr;
        }
    }
    
  • npack 46 posts 292 karma points
    1 week ago
    npack
    0

    As I interpreted it, your question was more about CSS grid than the Umbraco block grid. If that is not the case then disregard my answer and clarify.

Please Sign in or register to post replies

Write your reply to:

Draft