Ways to arrange objects to fill up space in a specific sequence

My HTML document contains two child HTML elements within the parent HTML. The parent HTML has a div with a class of .page, which is a large area for the children to occupy. Both children are of the same size and I need them to spawn in a specific order; for example, the first child component will be positioned at 1, and the next child should follow suit, either occupying space on the left or below if there is no room to the left.

Desired layout:

https://i.stack.imgur.com/vbC8J.png

Current layout:

https://i.stack.imgur.com/ulmfc.png

The CSS styling:

.page {
  display: flex;
  width: 26.4cm;
  height: 37cm;
  flex-wrap: wrap;
  align-content: flex-start;
  overflow: hidden;
}

Children's grid setup:

.displayGridSlip {
  display: grid;
  width: 13cm;
  grid-template-columns: 13cm;
  grid-template-rows: 1.7cm 4.9cm 0.5cm;
  grid-template-areas:
    "h"
    "b"
    "f";
  border-bottom-style: dashed;
  border-bottom-width: 0.3mm;
  border-right-style: dashed;
  border-right-width: 0.3mm;
  padding-top: 0.2cm;
}

Main HTML code snippet:

<div *ngFor="let itemCapa of arraySlips.capa; let k = index;">
    <div class="page">
        <app-slip-capa [itemCapa]="itemCapa"></app-slip-capa>
        <app-slip-conteudo [item]="arraySlips.info" [itemCapa]="itemCapa"></app-slip-conteudo>
    </div>
</div>

Answer №1

In my opinion, it may not be the best approach to use the .page class in the div after the *ngFor loop because it allocates the full 26cm width for each element instead of just half. Perhaps a better solution would be to utilize the .page class at the beginning of the div structure and then apply col-6 to the *ngFor div so that each element only occupies half of the column width:

    <div class="page">
        <div class="col-6" *ngFor="let itemCapa of arraySlips.capa; let k = index;">
            <div class="">
                <app-slip-capa [itemCapa]="itemCapa"></app-slip-capa>
                <app-slip-conteudo [item]="arraySlips.info" [itemCapa]="itemCapa"></app-slip-conteudo>
            </div>
        </div>
    </div>

Moreover, using centimeters as units might not be ideal. You can refer to this answer for more insights: . Feel free to experiment with other dimensions if needed. To achieve the desired layout where each element utilizes half of the page dimension, consider implementing code similar to the following example:

            <div class="row">
                <div class="col-6 div-to-the-left" *ngFor="let i of [0,1,2,3,4,5,6,7,8]; let k = index;">
                    <div class="">
                        <span>test {{i}}</span>
                    </div>
                </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

Hovering over rounded corners is being blocked by transparent areas

I have a setup that resembles the following: http://jsfiddle.net/NhAuJ/ The issue arises when hovering near the edges of the circle because the square div blocks interaction with the background. I want to ensure that the circular div in the middle remain ...

Yeoman webapp error: Issue with incorrect CSS path in subfolder

I have been using the yeoman webapp generator (0.5.0) and my app directory is structured like this: app/ ├── dir1 │ └── index.html ├── favicon.ico ├── images ├── index.html ├── robots.txt ├── scripts │ └ ...

Is there a way to emphasize certain words with angular?

In order to convert all words starting with "@" into an <a> (html link) element, I am looking for a solution using Angular 8 and considering the use of a custom pipe. For example, if the phrase is "Hello, @test" -> "Hello, <a href="...&qu ...

Ways to insert a gap underneath every line

Hello, I'm struggling to create space below each line of code. I've tried using the br tag and margin property, but it didn't work. Can anyone help me with this? I'm not sure if the current HTML structure is correct or if I should swit ...

Sending data from an HTML form to a div section without the need to refresh the entire page

I am currently working on a slide-down panel created in JQuery within a table. This panel includes a contact form where users can submit their information. My challenge is to post the form data to PHP without reloading the entire page, as the slide-down ...

`On mobile devices, the Bootstrap button no longer displays focus changes once clicked.`

When clicking a primary bootstrap button, it changes its background color to blue on mobile devices. For example, the first button appears normal and the second one turns blue after clicking. However, this background effect disappears when clicking anywhe ...

Is there a way to implement CSS transitions when hiding elements?

My bootstrap navbar collapses and displays items outside of it. However, when I hide the menu, the overlay div disappears immediately and does not transition smoothly with the menu. How can I apply a transition to the div when hiding the menu? I've t ...

Delivering static HTML content on Google App Engine using Python

I'm struggling to load static .html pages for my Python application. Every time I try to access a link like index.html, the page remains blank and the server log shows a 404 error. This issue persists with other static .html files such as about.html. ...

Trouble with jQuery: Background color fade in/fade out effects not functioning

Issue with changing background color during FadeIn and FadeOut effect. Whenever I click on the "whatup" link, my button should blink with alternating red and white colors. Below is the HTML code: <a id="blkwhatsup" href="#" >whatup</a> <in ...

What is the process for changing the border color of a Select Component?

Is there a way to change the border color of a select component in Material UI library without directly setting the property in inspect elements? I can see it working when I set the property that way, but how can this be achieved using class override? htt ...

Enhance your web design with the mesmerizing jQuery UI drop effect combined

I'm attempting to create an animated toggle effect on a box using jQuery UI's drop feature. However, I've encountered some trouble due to the box having box-sizing: border-box applied which is causing issues with the animation. During the a ...

Encountering issues during the installation of node modules within an Angular application

I encountered an issue while setting up my angular app. Upon trying to install the node modules using the command npm i --save, I received the following error message. Error: npm ERR! code ENOTFOUND npm ERR! errno ENOTFOUND npm ERR! network This is a pr ...

Customizing the layout of specific pages in NextJSIncorporating

In my Next.js project, I'm trying to set up a header and footer on every page except for the Login page. I initially created a layout.tsx file in the app directory to apply the layout to all pages, which worked fine. However, when I placed another lay ...

Update your AngularJS to the most recent version of Angular

We are faced with the task of upgrading a legacy MVC website that currently utilizes AngularJs to the latest version of Angular. Surprisingly, our current website only scratches the surface of what Angular has to offer - mainly using it for databinding and ...

Combine Two Values within Model for Dropdown Menu

I am currently facing a situation where I have a select box that displays a list of users fetched from the backend. The select box is currently linked to the name property of my ng model. However, each user object in the list also contains an email proper ...

Generate an image of a "button" with dynamic hover text

I am trying to create a clickable image with dynamically changing text overlaid on it. I have the PHP code that retrieves the necessary information for the text, but I am struggling to create the button as I am new to this type of task. Here is an example ...

Scroll through the div to quickly find the relevant content

I have implemented the following HTML structure: <div style="height:200px;overflow-y:scroll;"> <table>.....</table> </div> By using this setup, I am aiming to replicate the functionality of an expanded <select> control wit ...

When the back button is pressed on android, the navbar does not immediately refresh the active class

When using a webapp on Chrome for Android, pressing the back button results in double active items in the navbar. Clicking outside of the navbar removes the old active item. I attempted to resolve the issue by adding [routerLinkActiveOptions]="{ exact: tr ...

How can I extract text from nested HTML elements with a <a href> tag using the Jericho library?

Here is a snippet of my HTML code: <div class="itm hasOverlay lastrow"> <a id="3:LE343SPABGLIANID" class="itm-link itm-drk trackingOnClick" title="League Sepatu Casual Geof S/L LO - Hitam/Biru" href="league-sepatu-casual-geof-sl-lo-hitambiru-6816 ...

How can I customize the dropdown list arrow to match my own design?

Is there a simple way to substitute the standard arrow in the dropdown menu with a custom arrow image? ...