Utilizing CSS Grid to arrange child elements inside their respective parent containers

I am currently working on a grid container that contains multiple divs. Each div houses different elements such as headings, paragraphs, buttons, and logos. I have utilized Flexbox to evenly distribute the logos across the container's width. However, my goal is to position the div containing all logos at the very bottom of the grid container. Is there a way for me to achieve this layout? Below is the code snippet:

.grid-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.logos-container {
  display: grid;
  align-items: end;
}

.logos {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
<div class="grid-container">
  <div class="box">
    <div class="header">
      <h1>Making remote work</h1>
    </div>
    <div class="text">
      <p>
        Get your team in sync, no matter your location. Streamline processes, create team rituals, and watch productivity soar.
      </p>
    </div>
    <div>
      <button>Learn more</button>
    </div>
    <div class="logos-container">
      <div class="logos">
        <img src="images/client-databiz.svg" alt="databiz logo">
        <img src="images/client-audiophile.svg" alt="audiophile logo">
        <img src="images/client-meet.svg" alt="meet logo">
        <img src="images/client-maker.svg" alt="maker logo">
      </div>
    </div>
  </div>

  <div class="box">
    <img src="images/image-hero-desktop.png" alt="image">
  </div>
</div>

Answer №1

After making a few adjustments, I managed to achieve the desired outcome: https://jsfiddle.net/c1jx5p6u/1/

The key change involved relocating the logos-container outside of the box div and setting grid-areas accordingly.

This adjustment was necessary because having the logos-container within the box div caused it to be treated as one item in the grid areas. By moving it out, each logo could be positioned separately within the designated grid areas on the grid-container.

.grid-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  grid-template-areas:
    "head side"
    "main side"
    "footer footer";
}
.logos-container {
  display: grid;
  align-items: end;
  grid-area: footer;
}
.logos{
  display: flex;
  justify-content: space-between;
  align-items: end;
}
.box{
  grid-area: head;
}
.boxside{
  grid-area: side;
}

<div class="grid-container">
  <div class="box">
    <div class="header">
      <h1>Making remote work</h1>
    </div>
    <div class="text">
      <p>Get your team in sync, no matter your location. Streamline processes, create team rituals, and watch productivity soar.</p>
    </div>
    <div>
      <button>Learn more</button>
    </div>
  </div>
  <div class="logos-container">
    <div class="logos">
      <img src="images/client-databiz.svg" alt="databiz logo">
      <img src="images/client-audiophile.svg" alt="audiophile logo">
      <img src="images/client-meet.svg" alt="meet logo">
      <img src="images/client-maker.svg" alt="maker logo">
    </div>
  </div>
  <div class="boxside">
    <img src="images/image-hero-desktop.png" alt="image">
  </div>
</div>

Answer №2

https://i.sstatic.net/qdjFu.png

You have the flexibility to organize images according to your layout preferences.

.logos-container {
  display:flex;
  align-items: end;
}

.logos img{
  display: flex;
  justify-content: space-between;
  align-items: center;
}
<div class="box">
      <img src="images/image-hero-desktop.png" alt="image">
    </div>
    <div class="logos-container">
      <div class="logos">
        <img src="images/client-databiz.svg" alt="databiz logo">
        <img src="images/client-audiophile.svg" alt="audiophile logo">
        <img src="images/client-meet.svg" alt="meet logo">
        <img src="images/client-maker.svg" alt="maker logo">
      </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

What is the best method for choosing the parent elements?

I am attempting to create a sidebar that saves the last clicked link in local storage and still displays the collapsed links after the page is reloaded. $(".clickedLink").parent().parent().css('background-color', 'green'); Ca ...

Delay the next loop iteration until receiving an HTTP request

I have a task where I am collecting YouTube video IDs and storing them in an array. Then, I am looping through each video ID to determine the size of that ID's thumbnail image. My challenge now is making sure my loop waits for the HTTP request to fini ...

Strange spacing appears after image tags

My efforts to remove the space (red) between the <img> and the <div> have been unsuccessful. I have minimized it as much as possible. After researching similar threads, it seems that whitespace or newlines between inline-box elements can cause ...

if considering an integer value of 0 as equivalent to null

I am struggling with using axios to send data to an API in react. Despite the server successfully receiving the values, my code is not entering the if block as expected. Interestingly, when I make the same request from a rest client, it works perfectly. He ...

Angular select element is not functioning properly with the `addEventListener` method

My current project involves creating a table using the primeng library. The table consists of three rows and three columns, and all the data is static. Even though I am utilizing an external library, I find myself traversing the DOM directly. <p-table ...

What is the preferred convention for defining AngularJS directives as "attributes" versus "elements"?

When creating Angular directives, I've noticed that some directives could also be defined as either an HTML element or an attribute. I'm curious to know what the community convention is for choosing between the two, and the reasons behind it. Fo ...

What is the best way to integrate varying number formats based on user locale in UI5?

In my SAPUI5 app, I need to display numerical data based on the user's settings in the SU01 backend transaction in SAP Logon. For instance, users can specify decimal separators as: 22,000.000 (twenty two thousand) → US format 22.000,000 (twenty tw ...

The tab navigation feature is experiencing issues in Internet Explorer versions 7 and 8

I have successfully implemented a tab menu that functions well in Chrome and IE 9,10. However, it does not seem to work in IE 7 or 8. I am at a loss regarding what changes need to be made to my code. Could anyone provide assistance? Link to Code Example ...

How come my uploaded Excel Javascript add-on opens in an external browser instead of the task pane?

Note: It has come to my attention that I must save the taskpane.html file on my local drive before it opens in an external browser. This detail slipped my notice last week. I am currently developing a Javascript, or rather Typescript, API add-in for Excel ...

The primary container is brimming with an abundance of content

Can anyone help me with a CSS issue I'm experiencing in the latest versions of Chrome and Firefox? I can't seem to figure it out on my own. The problem arises with a container div that has a 50px top margin. Inside this container, there's a ...

Issues with Toggling Visibility in HTML, CSS, and Javascript

Currently, I am working on a website and following a tutorial called "Creating Slideshow using HTML, CSS, and Javascript" by W3Schools. In the project, I want to hide the thumbnail images located at the bottom and the navigation arrows initially and have t ...

Error: chunk.js encountered an unexpected token < and caused a syntax error

Hello friends, I find myself in need of some assistance. I recently deployed and built an application, but whenever I try to redirect to another page, I encounter this error: Uncaught SyntaxError: Unexpected token < I suspect that the issue lies in t ...

Exploring layered data through specific properties

Imagine a scenario where I have an array filled with data. Each element in this array is an object that could contain: an id some additional data a property (let's name it sub) which may hold an array of objects with the same properties (including t ...

showing text from chosen selection with an additional element included in the output

I could use some assistance with this code snippet. My goal is to showcase the options in the format: "Fried Rice = 10.000" as the outcome. However, the issue I am facing is that the select option box also contains the price. What I actually need is for th ...

Tips for handling Google Spanner Date type in JavaScript

I am facing a challenge with Google Cloud Spanner as I work with multiple tables containing columns of type Date. While inserting entries with specified dates works fine, the issue arises when trying to retrieve these entries in the JavaScript frontend. Th ...

Using Vue.js to display svg content inside the <svg> element

One of my Vue.js components is responsible for dynamically building the content of an svg element. Let's simplify things and say that the content consists of a <circle cx="50" cy="50" r="60" /> This component achieves this by manipulating a dat ...

"Troubleshooting the issue of AngularJS $http patch request failing to send

The information is successfully logged in the console when passed to replyMessage, but for some reason, the API does not seem to be receiving the data. Is the input field perhaps empty? replyMessage: function(data) { console.log(data); ...

What do you think about removing the Bootstrap styling from the design?

As a newcomer to Bootstrap and currently working on my second project using this framework, I find myself struggling with overriding CSS styles. It can be time-consuming to locate the specific style that needs to be changed rather than starting from scratc ...

Executing javascript whenever a page is updated

Looking for a solution to ensure that my userscript runs every time an AJAX call modifies any page it is attached to. Is there a way to listen for XMLHttpRequests and trigger the script accordingly? ...

Various web browsers are displaying distinct jQuery errors when executing the code

I'm currently working on validating and uploading images using multiple accept inputs with the help of jQuery, AJAX, and PHP. I have successfully added a validation function that is working correctly, but the form is not submitting. Additionally, Chro ...