Flexbox & Grid

Hello Guys!
While i was learning both i was struggling a bit with them. I understood what properties are and their specificities, but sometimes code doesn’t look like how i had aspected.
Just wondering if it’s better sometimes to use tools like layout generators to show up my idea of a website page without struggling too much with code editor, and learn step by step visualizing the layout generator.
Thank for any suggestion.

Happy Coding everyone

Marco

can we have a link to the code

<style>
    .angry-grid {
       display: grid;       
       grid-template: repeat(8, 1fr) / repeat(5, 1fr);
       gap: 5px;
       height: 100%;
       font-style: normal;
       font-family: monospace;
       color: blue;
       font-weight: 400;
       font-size: 13px;
    }
      
    #item-0 {
        padding: 5px;
       background-color: #DC758D; 
       grid-row: 1 / 2;
       grid-column: 1 / 6;
       
    }
    #item-1 {
        padding: 5px;
       background-color: #5CB6DD; 
       grid-row: 2 / 3;
       grid-column: 4 / 6;
       
    }
    #item-2 {
        padding: 5px;
       background-color: #DD87DF; 
       grid-row: 2 / 3;
       grid-column: 1 / 4;
       
    }
    #item-3 {
        padding: 5px;
       background-color: #7abca8; 
       grid-row: 3 / 7;
       grid-column: 1 / 6;
    }

    img {
        display: flex;
        flex-direction: row;
        justify-content: center;
        width: 100px;
        height: 100px;       
    }


    #item-4 {
        padding: 5px;
       background-color: #58B5D9; 
       grid-row: 7 / 8;
       grid-column: 1 / 6;
       
    }
    </style>
    
    <div class="angry-grid">
      <div id="item-0">"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."</div>
      <div id="item-1">"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."</div>
      <div id="item-2">"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."</div>
      <div id="item-3">"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
          <img src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAoHCBESFRASEhIRFBgQERISGBISEhoRGREWGhQZGRkaGRgcLi4lHB4rIRgZKDomKy8xNTU2GiQ7QDs1Py40NTEBDAwMEA8QHhISHjQnJCs0NDE0NTQ0NDExNTQxNDQ0NDQ2NDQ0NDQ0NDQ0NDQ0NDQxNDQ0NDQ0NDQ0NDE0NDQ0NP/AABEIALQBGQMBIgACEQEDEQH/xAAcAAEAAQUBAQAAAAAAAAAAAAAABwEDBAUGCAL/xABKEAACAQMBBQQFBwcJCAMAAAABAgADBBESBQYHITETQVFhNHF0gbEiMnORsrPRFEJSVHKCoRYkNZKTlMHD0iNFYoSio/DxFRcz/8QAGgEBAAMBAQEAAAAAAAAAAAAAAAEDBAIFBv/EACURAAMAAgEDBAMBAQAAAAAAAAABAgMRIQQSMSIyQVEzcZFhE//aAAwDAQACEQMRAD8A7uIiZz2RERAEREAREQBERAEREAREQBERAEREAREQBESkArEpKwBERAEREARKS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doYiAO0MdoYiAO0MdoYiAO0Mp2hiIBXtDHaGIgDtDHaGIgGTbHlnAzmZHaGUibcPtR5HU/kZXtDHaGUiXGcr2hjtDKRAK9oY7QykQCvaGO0MpEAr2hjtDKRAK9oY7QykQCvaGO0MpEAr2hjtDKRAK9oY7QykQCoqGWO0MROWD/2Q==" alt="lorem ispum">
        <img src="https://www.sololibri.net/local/cache-gd2/e9/4b9648ca0c6f8b33cb4270d790df47.png?1621432838" alt="lorem"><img src="https://i.guim.co.uk/img/static/sys-images/Guardian/Pix/pictures/2014/3/21/1395401774125/Lorem-ipsum-011.jpg?width=620&quality=85&auto=format&fit=max&s=33784a22dfb917cfeb9f3ebcc8726fcd" alt="ipsum"></img></div>
      <div id="item-4">"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."</div>
    </div>


Anyway the question was if sometimes it's better to use some shorcuts like layout generators when there's possibility.

That is the result I’m getting from the code. What do you want it to look like?

I want that #item-3 images where displayed cross the main axis and centered.

I cant figure it out Mabey somebody else can help you.

1 Like

Try out the online games flex-box zombies and Grid Critters. CSS layouts used to be the bane of my existence, but now I’m pretty good at them.

For the code you posted, do you want the text over the green background to stay as it is but have the 3 images directly underneath it all centered in a row? I can probably help, but I’m still not sure what end product you are envisioning.

1 Like

Thanks for the hint!
My intention was to display images as rows in the turquoise grid.
Anyway i think i had to wrap images inside another div and use display flex.
The issue was to display flex in the main one.

1 Like

Gotcha. Yeah one of the big things with grid is resisting the temptation to put too many rows and columns. Like you said, you can always put a flexbox inside a grid square to further subdivide it.

1 Like

Yes. At first times could be hard to understand, when you understand the process it’s so useful!

1 Like