PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, August 2, 2022

[FIXED] How to break dynamic <li> to the next line inside <ul> if there is more <li> in a column using html css?

 August 02, 2022     angular, css, html, html-table, javascript     No comments   

Issue

I am learning HTML and CSS. I am creating a table and inside it there is dynamic data.

In the below code I am using dynamic li inside a td.

But the problem is that the li data goes or overrides into next column as shown in below image. I want to break the li into next line and start below the first input box and continue that process.

How to achieve that any solution for that? Code:

HTML

         <td>
              <div class="dataset_number_container">
                <div class="dataset_number">
                  <!-- <p>Dataset Number</p> -->
              <input type="number" min="1" max="100" onkeypress="event.charCode >= 48" class="form-control datasetNo"
                placeholder="" [(ngModel)]="batchNumSmartData[i]" (blur)="getRangeSmartData(experimentnNamesmartdata[i], newDataset)"
                name="minBatchNum">
                </div>
                <div class="existing_number" *ngIf="newsmartDataset[i]">
                  <!-- <p>Existing Dataset Number</p> -->
                  <ul>
                    <li *ngFor="let row of existingSmartDatasetBatches[i]">
                      <input type="number" disabled = "true" value="{{row.batch_number}}">
                    </li>
                  </ul>
                </div>
              </div>
            </td>
            <td>
              <input type="text" class="form-control" placeholder="Objective" [(ngModel)]="Objectivesmartdata[i]" name="Objectivesmartdata" (change) = "changesmartobjective($event.target.value, i)">
        </td>

CSS

.dataset_number_container{
                    display: grid;
                    grid-template-columns: 32% 62%;
                    column-gap: 6%;
                    .dataset_number{
                        input{
                            width: 60px;
                        }
                    }
                    .existing_number{
                        width: 100px;
                        // margin-left: 10px;
                        ul{
                            list-style: none;
                            padding: 0;
                            margin: 0;
                            display: flex;
                            align-items: center;
                            vertical-align: middle;
                            // flex-wrap: wrap;
                            width: 100px;
                            li{
                                width: 40px;
                                height: 35px;
                                // margin-right: 5px;
                                // margin-bottom: 5px;
                                display: inline-block;;
                                justify-content: center;
                                align-items: center;
                                background: #F5F6FA;
                                border-radius: 4px;
                                font-weight: 500;
                                input{
                                    width: 40px;
                                    height: 35px;
                                    text-align: right;
                                }
                            }
                        }
                    }
                }

What I am getting enter image description here


Solution

your ul should add a

  flex-wrap: wrap;

If you want under the input the first input should be inside the "ul"

<td>
  <div class="dataset_number_container">
    <div class="existing_number">
      <ul>
        <!--the input under the "ul"-->
        <li>
            <input [(ngModel)]="batchNumSmartData[i]" .../>
        </li>
        <!--use ng-container to not create additionals tags-->
        <ng-container *ngIf="newsmartDataset[i]">
          <li *ngFor="let row of existingSmartDatasetBatches[i]">
            <input disabled="true" value="{{ row.batch_number }}"/>
          </li>
        </ng-container>
      </ul>
    </div>
  </div>
</td>


Answered By - Eliseo
Answer Checked By - Robin (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing