Adjusting column width in Bootstrap grid when content is missing

Currently, I am encountering a problem with the grid system while attempting to create a kanban style drag and drop system.

The issue is illustrated in the image below. Each card should be positioned according to the arrows shown. As the 2nd column is currently "empty" - meaning no cards are present in it yet - only padding is applied to it. https://i.sstatic.net/sVdFA.png

Previously, everything worked fine when all elements were in the same column, and the header (color-coded card) was also in that column, ensuring the correct width.

However, I needed to separate the header to implement a sticky behavior where the header remains at the top when scrolling vertically.

The template structure is as follows:

<div #autoscroll
     class="col wholeTable">
  <div class="row pipe-header">
    <ng-container *ngFor="let stage of cardList; let i = index">
      <div class="col">
        <ng-container *ngIf="pipelineConfig.headerTemplate; else noHeaderForYou">
          <ng-container
                        *ngTemplateOutlet="pipelineConfig.headerTemplate; context : {$implicit: headerList[i], count: cardList[i].items.length}">
          </ng-container>
        </ng-container>
        <ng-template #noHeaderForYou>
          <!-- Displaying some useful info even if no custom template is present-->
          <dt-pipeline-header [label]="headerList[i].elementLabel"
                                     [count]="cardList[i].items.length">
          </dt-pipeline-header>
        </ng-template>
      </div>
    </ng-container>
  </div>

  <div class="row stage">
    <ng-container *ngFor="let stage of cardList">
      <div class="col"
           dragula="cardList"
           [(dragulaModel)]="stage.items"
           attr.id="{{stage.key}}">
        <ng-container *ngFor="let item of stage.items">
          <div class="card"
               [ngClass]="{
                    'dragabble' : pipelineConfig.permissionChecker(item),
                    'nodrag': !pipelineConfig.permissionChecker(item)
                  }">
            <div class="card-body">
              <ng-container *ngIf="!pipelineConfig.permissionChecker(item)">
                <span class="disabled-indicator"><i class="fas fa-ban"></i></span>
              </ng-container>
              <ng-container
                            *ngTemplateOutlet="pipelineConfig.bodyTemplate; context: {$implicit: item, showColumns: showContent}">
              </ng-container>
            </div>
          </div>
        </ng-container>

      </div>
    </ng-container>
  </div>
</div>

component.css:

@media only screen and (max-width: 600px) {
  .wholeTable {
    display: block;
  }
}

.stage {
  word-break: break-word;
  min-height: 100%;
  flex-wrap: nowrap;

  .col {
    min-width: min-content;
  }
}

.card.dragabble:hover {
  cursor: grab;
}

.card.dragabble, .card.nodrag {
  margin: 1rem 0rem;
}

.pipe-head-divider {
  margin-bottom: 0;
}

.disabled-indicator{
  display: flex;
  float: right;
  position: relative;
  top: -0.5rem;
  right: -0.5rem;
}

.wholeTable {
  overflow-x: scroll;
  overflow-y: hidden;
  flex-wrap: nowrap;
}

.pipe-header {
  flex-wrap: nowrap;
}

Answer №1

The current rule in place already sets a minimum width for the columns:

  .col {
    min-width: min-content;
  }

If you have a specific minimum column width in mind, you can adjust the value of min-content to that desired width, whether in pixels in the CSS or using [style.min-width] if you can predict it.

Alternatively, if you have a "sticky" top row and other columns within the same container, you can selectively apply the sticky behavior to only the top cards by marking them with a special attribute in the data model.

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

Issues with Internet Explorer

I am currently working on an aspx page that displays perfectly in Mozilla Firefox but looks distorted in Internet Explorer. The layout in Mozilla appears like this: <form> some stuff <div class="left"> <div class="right> </form> H ...

Click on the button to open the generated link in a new tab

How can I efficiently open a URL in a new tab after making an API call with the click of a button? Currently, the button triggers the API call and generates the URL. <button (click)="getUrl()">Connect</button> In TypeScript: getUrl() ...

How to transfer a java list to an html template

I have extracted some information from an HTML file that relies on input from a Map structure as demonstrated below Template t = TemplateLoader.load("Printing/account.html"); Map<String, Object> map = new HashMap<String, Object>(); map.put("a ...

Unable to adjust the text color to white

As someone who is new to Typescript, I'm facing a challenge in changing the text color to white and struggling to find a solution. I'm hoping that someone can guide me in the right direction as I've tried multiple approaches without success ...

Incorporating interactive maps into an AngularJS web application

I've been attempting to integrate Google Maps into my AngularJS application, using the script tag below: <script src="https://maps.googleapis.com/maps/api/js?key=[MySecretKeyHere]&callback=initMap" async defer></script> I found this ...

Resize an image to automatically adjust and fit within a designated container

Is there a way to resize an image automatically to fit inside a container with a blank background? Currently, the structure looks like this: <div class="row"> <div class="col-md-3"> <div class="panel panel-primary"> ...

Whenever I select a link on a navigation bar, it transports me to the desired section of the page. However, I often find that the navbar ends up

Recently, I came across some website templates where clicking on a link in the navbar smoothly scrolls to the corresponding section with perfect alignment. The content at the top of the page aligns perfectly with the top of each division. Upon attempting ...

Adjust the font size within a container using HTML code, no CSS required

Is it possible to directly change the TextSize and TextColor within the HTML Document? I need it to be within this specific box (same class) because of the background color. However, the text size always remains the same. The HTML line is: Which button re ...

Can you guide me on implementing a transition animation through class toggling?

I am facing an issue where certain elements need to be highlighted or unhighlighted conditionally. To achieve this, I have assigned a class called highlight to the elements that require highlighting with a transition animation. The challenge arises when t ...

When I run ng build, an error code ".form-floating>~label" pops up

After running the command "ng build" in my Angular app, I encountered the following output: ✔ Browser application bundle generation complete. ✔ Copying assets complete. ⠋ Generating index html...4 rules skipped due to selector errors: .form-floatin ...

Changing the width of the file input using css

Clicking just below the word demonstration also triggers a click on the input type file. How can this be avoided so that the click event only fires in the intended area regardless of size? <!DOCTYPE html> <html> <body> <style> in ...

Is it possible to assign a name attribute to the <img> tag in HTML?

Can the "name" attribute be used in an "img" tag in HTML? If you have this knowledge, please do share and thank you in advance. ...

Error: Papa is not defined. The file was loaded from the CDN in the header section

I have integrated the cdn hosted lib for PapaParse in my HTML header. However, when I execute my JavaScript file and it reaches the function where I call Papa.unparse(data); It throws an error stating that Papa is undefined. This has left me puzzled as I h ...

Animated drop-down menu in Angular 4

I recently came across this design on web.whatsapp.com https://i.stack.imgur.com/ZnhtR.png Are there any Angular packages available to achieve a dropdown menu with the same appearance? If not, how can I create it using CSS? ...

Having trouble aligning my CSS form correctly

The issue is with the alignment of the second row of textbox elements under the "Add Equipment" section on this page: While organizing the code in Dreamweaver, the elements line up correctly. However, when viewed in Google Chrome, they shift to the second ...

What is the best way to align this content in a specific area?

How can I center the content in each section of my webpage? Here is an image for reference: https://i.stack.imgur.com/PHEXb.png I want Section 1 and Section 2 to be 100vh with the content centered on the page. .content { height: 100vh; } <!do ...

Incorrect outcome when utilizing ajax to update a div within a for each loop

For a while now, I've been facing an issue with a div and form within a forEach loop. When one of the forms in the loop is submitted, the content inside the corresponding div is updated in the database and refreshed using JavaScript and Ajax. The upda ...

Tips on how to maintain the value of an integer variable even after clicking a submit button, enabling its reuse on the same page

Take a look at the first part of this code where we are using the variable $Tno. if(isset($_POST['submit'])) { $Tno=$_POST['Tno']; $query="SELECT * FROM docs WHERE Tno='$Tno'"; $result=mysql_query($query) or di ...

How can I determine the specific quantity of XPATH links with unique identifiers in Selenium?

Seeking automation with Python3 and selenium to streamline searches on a public information site. The process involves entering a person's name, selecting the desired spelling (with or without accents), navigating through a list of lawsuits, and acces ...

Loop through JSON results in Ionic using Angular

I am struggling to retrieve data from a JSON file in Object format using Typescript. When I try to fetch the data from the API, it doesn't display as expected. Typescript this.http.get('http://example.com/api') .subscribe((data) => { ...