Setting a specific width for columns when utilizing more than 12 columns in a row in Bootstrap 3

Utilizing bootstrap 3 in this particular case.

I currently have an HTML table with more than 12 rows, about 14 in total. These rows consist of various input controls such as textboxes and dropdowns. My goal is to set a fixed width for each column, for example, text would have a certain width, dropdowns another, and so on. Below is my current table design:

    <table class="table table-bordered" style="">
      <thead>
        <tr>
          <th>Col1</th>
          <th>Col2</th>
          <th>Col3</th>
          <th>Col4</th>
          <th>Col5</th>
          <th>Col6</th>
          <th>Col7</th>
          <th>Col8</th>
          <th>Col9</th>
          <th>Col10</th>
          <th>Col12</th>
          <th>Col13</th>
          <th>Col14</th>
        </tr>
      </thead>
      <tbody>
        <tr ng-repeat="c in data">
          <td>{{c.name}}</td>
          <td>
            <select name="" class="form-control" ng-model="">
                            <option value="">--Select--</option>
                            <option ng-repeat=""></option>
                        </select>
          </td>
          <td>
            <select name="" class="form-control" ng-model="">
                            <option ng-repeat=""></option>
                        </select>
          </td>
          <td><input type="text" name="" ng-model="" class="form-control" /></td>
          <td><input type="text" name="" ng-model="" class="form-control" /></td>
          <td><input type="text" name="" ng-model="" class="form-control" /></td>
          <td><input type="text" name="" ng-model="" class="form-control" /></td>
          <td><input type="text" name="" ng-model="" class="form-control" /></td>
          <td><input type="text" name="" ng-model="" class="form-control" /></td>
          <td><input type="text" name="" ng-model="" class="form-control" /></td>
          <td><input type="text" name="" ng-model="" class="form-control" /></td>
          <td><input type="text" name="" ng-model="" class="form-control" /></td>
          <td><input type="text" name="" ng-model="" class="form-control" /></td>
        </tr>
      </tbody>
    </table>

I attempted to define the style for each TH element as follows:

 <th style="width:10%">Col1</th>

The problem is that this method partially works, but once the last few columns reach the edge of the screen, their width automatically decreases even if I specified a width for them.

As a solution, I tried giving my table a width and enabling auto-scroll like so:

style="overflow-x:auto;min-width:100%"

However, this approach also proved ineffective.

Could someone provide guidance on how to establish a fixed width for each column? Horizontal scrolling is acceptable in this scenario.

Thank you

Answer №1

If you want to set a specific width for the form-control class, simply add a fixed value like in the following example:

.form-control {
   width: 200px;
}

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

How to Customize the ::before Pseudo-element for a mat-expansion-panel-header?

I have a demo where I am attempting to customize the appearance of the mat-expansion-panel-header's ::before pseudo element with the following CSS rules added to styles.scss: mat-expansion-panel-header { position: relative; } mat-expansion-panel-he ...

Customizing Bootstrap CSS

In my recent code, I included a bootstrap css reference in this manner: <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5T ...

Unable to display images in the ngImgCrop upload preview modal screen

Currently, I am utilizing ngImgCrop to enable an upload preview and square crop feature for profile pictures. Unfortunately, I am experiencing issues where neither the image preview nor the cropping functionality are being displayed. 'use strict ...

Uploading profile photos via PHP and storing in a database

I am encountering an issue where the uploaded photo appears on the site but its corresponding name is not being saved in the database. The code successfully uploads the photo to the site but unfortunately, the file name is not being stored in the database. ...

Tips for modifying the property value of a navigation bar in Bootstrap using Sass

I currently have a navigation bar on my webpage that is styled with the following CSS properties: .navbar { position: relative; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; padding: 0.5rem 1r ...

The v-for directive is unable to access the prop data

<template> <span> <i class="fa fa-star text-warning fa-2x" v-for="r in rating" :key="r"></i> <h1>{{rating}}</h1> </span> </template> <script> ...

Is there a way to eliminate the gap between two horizontal rule tags?

What causes the space between two <hr> tags to remain? Despite setting the width of the <hr> tags to 49%, there is still a gap between them. How can this space be removed from the <hr> tags? Shown below is the HTML and CSS code: *{mar ...

Show validation error messages for radio buttons alongside images in a single row

Within a div, I have placed three radio buttons with images inline. My goal is to show a validation message using bootstrap when the submit button is clicked and there is no user input. I attempted to add another div after the radio buttons with the class ...

The basic spinning hover animation is not functioning properly

Can anyone help me with creating a hover effect on an inner circle that causes two outer rings to rotate? I've been struggling to make it work as expected. When I hover over the inner circle, the outer rings only move to the bottom right corner withou ...

HTML list style with varying images at the same level in a ul tag

I am working on an Application that generates output with li tags. I am trying to find a way to apply different list-style-image for each li tag of the same level within the ul, while keeping the HTML code as simple as possible. Each li with a class of gre ...

Using jQuery to append text after multiple element values

I currently have price span tags displayed on my website: <div> <span class="priceTitle">10.00</span> </div> <div> <span class="priceTitle">15.00</span> </div> <div> <span class="priceTitle">20.0 ...

Calculator screen filled with numbers overflowing beyond its boundaries

I'm encountering an issue with my calculator created in create-react-app where the numbers are overflowing off the screen. Specifically, when inputting very large numbers like 11111111111111111111111111111111, they exceed the output container. I am lo ...

Issue with Framework7: Swiper slider link not functional

On one of the slides in my swiper slider, there is a link that redirects to a file named year.html Here is the link: <a href="year.html">Add by year, make & model</a> Source code for swiper slider: http://pastebin.com/ggN3TqgA Content ...

Can you please explain the functionality of this CSS code?

*:first-child+html .clearfix{zoom:1px;} Can anyone explain the purpose of this code snippet? I noticed it was causing elements to render at 1px in Internet Explorer 7. This code is present in the style.css file of my WordPress theme (created by ElegantThe ...

Designing a popup using Angular, CSS, and Javascript that is capable of escaping the limitations of its parent div

I'm currently working on an Angular project that involves components nested within other components. My goal is to create a popup component that maintains the same size and position, regardless of where it's triggered from. One suggestion I rece ...

What are the pros and cons of embedding background image data into CSS as Base64?

While examining the source code of a greasemonkey userscript, I came across some interesting CSS: .even { background: #fff url(data:image/gif;base64,R0lGODlhBgASALMAAOfn5+rq6uvr6+zs7O7u7vHx8fPz8/b29vj4+P39/f///wAAAAAAAAAAAAAAAAAAACwAAAAABgASAAAIMAAVCBxIsK ...

Should input fields be placed inside separate columns or share a column in Bootstrap to keep them together while being right justified?

When using Bootstrap, is it better to place separate input fields inside their own col or share a col to keep them together and right-justified? I have a combo and input that I want to display on the same row at the right-hand side of the screen. If I put ...

Safari browser is experiencing issues with the custom file upload script

My custom upload script allows users to easily select images for upload by clicking or dragging them into the designated box. A preview of the chosen image should appear, and this functionality works smoothly in Firefox and Chrome. However, I've encou ...

Attempting to maintain the main navigation highlighted while browsing through the secondary navigation

I am facing a small issue that seems like it should be an easy fix, but I can't seem to figure it out. While working on my site, I'm having trouble keeping the parent navigation highlighted when scrolling through the sub-menu. If you hover over ...

The exact measurement of width is not specified in the custom element that extends HTMLCanvasElement

I have created a custom element that extends a canvas, but when I try to add it to the DOM, the width appears to be undefined. Here is my code snippet. class Renderer extends HTMLCanvasElement { constructor() { super(); } } customElements.def ...