Arrange objects in dropdown menu to line up

I'm currently working on a dropdown menu and I have a specific requirement – the menu should always be split into two columns and be able to span multiple lines. However, I've encountered an issue where the columns are not aligned properly, causing them to be at different positions.

Could someone provide me with guidance on how to ensure that all elements in my dropdown menu are properly aligned?

Thank you for your help.

VIEW DEMO

HTML Snippet:

<ul class="list-group">
  <div *ngFor="let menu of ArrayMenu">
    <div *ngIf="menu.sons == true">
      <div class="dropright">
        <div class="myListGroup" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
          <img class="img-responsive" src="data:image/png;base64,{{menu.icon}}">
          <span>{{menu.desc}}</span>
        </div>
        <div class="dropdown-menu mydropdown">
          <div *ngFor="let item of ArrayMenu">
            <div *ngIf="item.idMenu == menu.id" style="width: 100%;height: 100%;margin: 8px;">
              <div class="divFilhos">
                <img class="img-responsive" src="data:image/png;base64,{{item.icon}}">
                <span>{{item.desc}}</span>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</ul>

Issue Example:

https://i.sstatic.net/5EtXf.png

Answer №1

You have specified margin for the elements in your HTML, consider changing it to padding.

<div *ngIf="item.idMenu == menu.id" style="width: 100%;height: 100%;padding: 8px;">

Check out the demo here

Answer №2

If you notice a gap at the top of the second column, it may be due to the way columns flow on the page. To fix this, try adding 'display: inline-block' to the child element. Check out this demo for more info.

<div *ngIf="item.idMenu == menu.id" style="width: 100%; height: 100%; margin: 8px; display: inline-block;">

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

Utilizing AngularJS and Bootstrap popover: A guide to effectively implementing "popover-is-open" within an ng-repeat loop

When utilizing ng-repeat to generate a table with items, each item has a button in its row that opens a popover for editing the object. I want to avoid using the click-outside property of the bootstrap popover because I only want the popover to close when ...

Removing Multiple Object Properties in React: A Step-by-Step Guide

Is there a way in React to remove multiple object properties with just one line of code? I am familiar with the delete command: delete obj.property, but I have multiple object properties that need to be deleted and it would be more convenient to do this i ...

Utilizing CSS to incorporate a background image into HTML code

Is it feasible to utilize pure HTML for the background-image property? Consider the following scenario: The original: background-image:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' version='1.1' height=&apo ...

receiving list items in JSON format rather than XML or Atom

Upon typing the link of a list in my browser, I am able to view all the data in xml/atom format. The screenshot can be found below: https://i.sstatic.net/9jUKV.png In my search for converting this incoming response to JSON, I utilized the "RequestOptionsA ...

Which element to use for creating a color palette - <img>, <div>, or <canvas>?

I am currently in the process of developing a color-picker component using HTML, CSS, and Javascript. One key question that I have is how to best implement a color palette similar to the one below: Putting aside browser compatibility concerns with IE8 or ...

Utilizing Ajax to fetch a div element from a web page

Hey there! I have a link set up that loads a page into a specific div ID, which is #ey_4col3. The issue I'm facing is that it loads the entire page along with all its contents, but what I really want to load from that page is just the content within ...

The fieldset css in PrimeNG differs from the website's original design

On my website, the appearance of the fieldset can be seen here: https://i.stack.imgur.com/TTS8s.jpg. I did not make any CSS changes that altered the fieldset. I am utilizing primeNG v7 and Angular 7. <p-fieldset legend="Toggleable" [toggleable]="true" ...

Vertical Positioning of Tabs in Materialize CSS

My current challenge involves creating vertical tabs using materialize CSS, specifically in regards to positioning. The desired outcome is for the content to align at the same level when clicking on TAB 3. An example of the expected result can be seen in t ...

Is there a "Read more" link to expand the content on the page?

I am struggling to figure out why my JavaScript code for toggling between showing more text and less text is not functioning correctly. My goal is for the user to click on the "Show More" button to reveal additional text, and then be able to click on "Show ...

Tips for utilizing rowspan and colspan in BootstrapTable

I am creating a table using bootrapTable and would like to know how I can use rowspan or colspan to achieve a table layout similar to the one shown in this image: Click here for image description $table.bootstrapTable({ columns: [{ ...

How should attributes be passed to the li element properly?

I am trying to transfer values from the database to the <li> tag. Can someone confirm if the approach below is valid and the proper way to do it? <li id='$current_row["RA_SUB_ID"]' component_name='$current_row["RA_SUB_NAME"]' ...

Display on click within a nested array

Within my array of teams, I have nested arrays containing players' information. JSON file "id": 1, "Name": "TEAM A", "Active": true, "created_at": "2019-09-12T13:56:52.045Z", "updated_at": "2019-09-12T14:30:42.533Z", "Players": [ { "id": 1, ...

Is there a way to efficiently retrieve and handle multiple $_POST records in PHP simultaneously?

I am currently working on developing a management interface that allows administrators to make bulk edits to members of a website all at once. While we already have the capability for single edits, there is a need for an option to modify all users simultan ...

How to dynamically add a route from an HTTP API to the app-routing.module.ts file in Angular 10

Struggling with an issue while working on Angular 10 version. Despite finding numerous solutions for older versions of Angular, I am still unable to resolve the issue. I consider myself a beginner in Angular as I try to create a website using an Angular c ...

How can I display milliseconds from a date in Angular2+?

I recently encountered an issue while working with a custom pipe that was used to display time. I attempted to modify it so that it could also show milliseconds: {{log.LogDate|jsonDate|date:'dd.MM.yyyy &nbsp; HH:mm:ss.sss'}} Here is the cod ...

Does @angular/router have a similar function to ui-router's transition.from()?

I am currently in the process of updating an Angular application from ui-router to @angular/router (v6). There is a specific function that aims to retrieve the previous route. Below is the code snippet utilizing Transition from ui-router/core: const ...

Tips for utilizing the data-target feature in Bootstrap?

<button id="btn-id" class="navbar-toggler" type="button" data-toggle="collapse" data-target="#bs-navbar-collapse-1"> <span class="navbar-toggler-icon"></span> <span c ...

The flex-direction property is not behaving as anticipated in the Chrome browser

Hi everyone, I really need some assistance with my code. The flex-direction property is not working for me no matter what I try. I've tested it on both Chrome and Microsoft Edge, but it displays the same result. I've been stuck on this for the pa ...

Incorporating a class into ever-changing Bootstrap Table rows

Looking to enhance my table rows with a class, excluding the header. Struggling to find a way to do this. Any ideas? This is the table in question: <table id="table" class="hidden table table-bordered table-striped table-hover"> <thead> ...

The error message 'tagName' is not a valid property for type ChildNode in Typescript

When I loop over childNodes from a parent node, I encounter an issue while trying to access the tagName of the child nodes. The error message states that tagName does not exist on type ChildNode. const contentParsed = new DOMParser().parseFromString(conte ...