Creating consistent div sizes for varying image and title lengths in bootstrap

In my angular project, I am receiving data in the form of image, title, and location. Despite my efforts to create a responsive div, I have been unsuccessful in achieving uniform sizes.

      <div *ngFor="let company of companies" class="col-xl-2 col-lg-3 col-md-4 col-sm-6 col-12">
        <div class="card">
          <div class="card-content">
            <div class="card-body py-0 text-center">
              <input [checked]="true"   type="radio" formControlName="scope" (click)="nextFormPostion(nextFormPostionName)"  (change)="nextFormPostion(nextFormPostionName)"  id="img{{company.scope}}" class="d-none imgbgchk" value="{{company.scope}}">
              <label  for="img{{company.scope}}">
                <div class="row justify-content-center">
                  <div class="col-12" style="height: 6rem ; display:table-cell; vertical-align: middle;">
                    <img  src="{{company.logo}}"  class="mt-1 img-fluid mh-100" alt="Image 1">
                  </div>
                  <div class="col-12 mt-2" style="min-height: 3rem;font-size: 12px;text-transform: none;">
                    <span>{{company.company}}</span>
                  </div>
                  <div class="col-12 mt-1" style="min-height: 2.5rem;font-size: 12px;text-transform: none;">
                    <span>{{company.country}}</span>
                  </div>
                </div>

                <div class="tick_container">
                  <div class="tick"><i class="fa fa-check"></i></div>
                </div>
              </label>
            </div>
          </div>
        </div>
      </div>

The company.logo represents the image path, while company.company indicates the name of the company. My goal is to align the images vertically and horizontally at the center and automatically adjust the div sizes if the length of the company name requires a new line.

Answer №1

Forget about relying on bootstrap for this task, JavaScript can handle the job just fine by allowing you to specify the dimensions of a div element using width and height properties.

In addition, CSS offers another approach:

width: 100%

Answer №2

To troubleshoot any issues with your code, it's important to first check for any border, margin, or padding that may be affecting the layout. Without sufficient information, it's hard to pinpoint the exact problem. It's possible that Bootstrap is adding automatic padding to elements like .row.

One solution is to add the following code:

<div class="row g-0">
</div>

Bootstrap 5 - No gutters

If the issue persists in another element, consider adding the px-0 class to remove padding from the widths.

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

The benefits of utilizing "native tags" instead of foreignObject in an SVG

As the creator of the stackoverflow-readme-profile project, I dedicated extensive time and effort to crafting a personalized Stackoverflow profile in the form of an SVG image. Utilizing "native svg tags," I meticulously constructed elements such as: < ...

Issue with angular 8 radio button not being selected

Here is the HTML code I am working with: <div *ngFor="let option of systemEquipmentGroup"> <h5>{{option.optionGroupName}}</h5> <div> <label style="display: block;" * ...

Angular 2: A ready-made solution for developing interactive discussion features

Currently working on my Angular 2 application and looking to incorporate a discussion feature. Are there any pre-existing solutions available for this integration? ...

Tips for modifying the appearance of a text file within an iframe

Lately, I've been facing a dilemma on my website. I have an iframe code that looks like this: <iframe src ="http://hokuco.com/cde/user.txt" id ="myIframe"></iframe> However, the consolas font used in the iframe makes my website appear ...

Can a screenshot of a YouTube video be printed exactly as it appears on a website?

Is there a way to print a page with an embedded YouTube video without it showing up as a blank area? I want the printed version to display the same still shot that appears on the web. If this isn't possible, I will use a noprint stylesheet. Here is ho ...

Show a picture on top of another picture

Is there a way to overlay an image and text on top of another image, similar to what is done on this website ? ...

Unable to bring in the directive from the Angular library

I've created this custom Directive within my library: @Directive({ selector: '[layoutHeaderTitle]', standalone: true }) export class HeaderDirective { constructor( readonly tpl: TemplateRef<any>, private re ...

Issue found in Bootstrap-Multiselect plugin: The dropdown menu appears beneath the outer container when overflow-y is applied

My experience with using Bootstrap-Multiselect and encountering an issue where the dropdown disappears when the outer container has overflow-y: scroll and a max-height has prompted me to seek solutions. I am looking for a way to ensure that the dropdown is ...

Placing an eye icon on the password input field for optimal visibility and positioning

I am currently working on a Node.js project and I am attempting to incorporate an eye icon using Bootstrap into the password input field for visibility. Below is the code snippet of my input field: <div class="container"> <form ...

Adjusting the dimensions of a button: What to expect

I'm currently working on a toggle switch that I want to make responsive for future resizing. The toggle switch includes a red square (for demonstration purposes), but I've encountered an issue where the red square stretches and changes its dimens ...

Assigning initial value to a BehaviorSubject in an Angular application

I'm still getting the hang of Rxjs. How do I go about initializing the first value of a BehaviorSubject with data from a custom select box model? Here's what the model looks like: private mainRangeDate: any = {beginDate: {year: 2018, mon ...

Bizarre display of miscellaneous items on the monitor

Hey there, I've been working on creating a div to display information about both the Civilian and Vehicle that users input. Initially, everything worked perfectly with my HTML and CSS until I introduced two additional divs into the layout. With just o ...

Angular4 and jQuery working together for effective navigation and pagination

Trying to implement pagination in angular 4 and jQuery, but encountering an issue where clicking on the next button causes it to skip through multiple pages at once (2, then 3, then 5)... Component code: addClass(x) { $(".page-item").click(function () ...

Is there a way to create a transparent color for the Dropdown Toggle?

As I work on expanding my understanding of HTML and Bootstrap, utilizing Bootstrap version 5.3.0 Alpha 3, I encounter an issue with the Dropdown feature. Typically, when a Dropdown is used within an element such as an icon or text, it displays an arrow sym ...

Combining MySQL tables for main menu and subcategories

Working on a new project and seeking help with a certain situation. I have a SQL database featuring two tables: menu and submenu. The table structure is as follows: Menu: id | title | order Submenu: id | title | parentId Currently, I'm using two si ...

What are the signs that an element was visible on screen prior to navigation?

Recently, I incorporated SlideUp and SlideDown jquery animations into my website. You can check it out by visiting (click the >>>). However, I noticed a small issue where when users navigate to a new page, they have to re-SlideUp the element that ...

Having trouble with your jQuery animation on a div?

Check out this jsFiddle example: http://jsfiddle.net/uM68j/ After clicking on one of the links in the demo, the bar is supposed to smoothly slide to the top. However, instead of animating, it immediately jumps to the top. How can I modify the code to ac ...

ngx-capture : Issue with capturing the entire page

Hey there! I'm currently using the ngx-capture package for capturing images, but I've encountered a problem. It seems to only capture the area that is visible in the browser. Is there a way to capture the whole page or an entire div? I came acr ...

Retrieve the parent route component in Angular

I am in the process of developing an Angular 7 application that features nested routes. My goal is to identify the specific component being used by the parent route. While I have managed to achieve this locally, the method fails in a production environment ...

Center sidenav material 2 in alignment

Using Angular Material 2 presents a challenge for me: While I can align the text in the sidenav to center, I am struggling to align the button correctly. https://i.sstatic.net/vjHw4.png <md-sidenav-layout fullscreen> <md-sidenav #start mode=" ...