Responsive design in Bootstrap(-Vue) with compact input fields

I am currently working on creating an input form with small fields and signs between them. https://i.sstatic.net/THjhs.png

Right now, I am using a combination of classic HTML and Bootstrap-Vue, as shown in the screenshot. It is functional, but the issue is that it is not responsive on mobile screens. Here is how it looks on mobile:

https://i.sstatic.net/nnbSB.png

The last field gets covered by the button, and the fields themselves are too small to display the input properly.

If I use only Bootstrap, the fields and spacings become too large, and I struggle to make them smaller. I believe having the button on a new line on mobile would be a better approach. But, how can I achieve this?

Here is a snippet of my code:

<b-row>
  <b-col class="mt-3" cols="2">
    &nbsp;
  </b-col>
  <b-col class="mt-3">
    <b>Kundennummer:</b>
  </b-col>
</b-row>
<b-row>
  <b-col class="mt-3" cols="2">
    &nbsp;
  </b-col>
  <b-col class="mt-3 ml-0" cols="4">
    <table>
      <tr>
        <td class="m-0 p-0">
          <b-form-input id="case_no_0" ref="case_no_0" type="text" v-model="custNo[0]" :state="state[0]" maxlength="3" @focus="$event.target.select()" @input="formatter(0)"></b-form-input>
        </td>
        <td class="m-0 p-0">
          &nbsp;.&nbsp;
        </td>
        <td class="m-0 p-0">
          <b-form-input id="case_no_1" ref="case_no_1" type="text" v-model="custNo[1]" :state="state[1]" maxlength="3" @focus="$event.target.select()" @input="formatter(1)"></b-form-input>
        </td>
        <td class="m-0 p-0">
          &nbsp;.&nbsp;
        </td>
        <td class="m-0 p-0">
          <b-form-input id="case_no_2" ref="case_no_2" type="text" v-model="custNo[2]" :state="state[2]" maxlength="3" @focus="$event.target.select()" @input="formatter(2)"></b-form-input>
        </td>
        <td class="m-0 p-0">
          &nbsp;-&nbsp;
        </td>
        <td class="m-0 p-0">
          <b-form-input id="case_no_3" ref="case_no_3" type="text" v-model="custNo[3]" :state="state[3]" maxlength="4" @focus="$event.target.select()" @input="formatter(3)" @keyup.enter="validateAndSave()"></b-form-input>
        </td>
      </tr>
    </table>
  </b-col>
  <b-col class="mt-3">
    <b-button class="btn-evm-orange" @click="validateAndSave()">Senden</b-button>
  </b-col>
</b-row>

EDIT:

For those wondering why I don't solely use Bootstrap and in response to Sirence's answer

The fields become excessively large with Bootstrap alone, while I aim to keep them small and compact, just enough for three numbers. Here is a comparison of screenshots:

PC-View

https://i.sstatic.net/xdl0W.png

Mobile-View

https://i.sstatic.net/m2tgh.png

Answer №1

If you're looking to create a responsive form without using a table, you can achieve this by utilizing the bootstrap responsive col classes along with some utility classes:

  <b-row class="no-gutters">
  <b-col class="col-2 col-md-1">
    <b-form-input type="text" maxlength="3"></b-form-input>
  </b-col>
  <b-col class="col-auto align-self-end">&nbsp;.&nbsp;</b-col>
  <b-col class="col-2 col-md-1">
    <b-form-input type="text" maxlength="3"></b-form-input>
  </b-col>
  <b-col class="col-auto align-self-end">&nbsp;.&nbsp;</b-col>
  <b-col class="col-2 col-md-1">
    <b-form-input type="text" maxlength="3"></b-form-input>
  </b-col>
  <b-col class="col-auto align-self-center">&nbsp;-&nbsp;</b-col>
  <b-col class="col-2 col-md-1">
    <b-form-input type="text" maxlength="4"></b-form-input>
  </b-col>
  <b-col class="col-12 col-sm-auto pt-2 pl-sm-3 pt-sm-0">
    <b-button class="btn-evm-orange">Button</b-button>
  </b-col>
</b-row>

To create a two-row layout on extra small devices:

<b-row class="no-gutters">
  <b-col class="col-3 col-sm-2 col-md-1">
    <b-form-input type="text" maxlength="3"></b-form-input>
  </b-col>
  <b-col class="col-auto align-self-end">&nbsp;.&nbsp;</b-col>
  <b-col class="col-3 col-sm-2 col-md-1">
    <b-form-input type="text" maxlength="3"></b-form-input>
  </b-col>
  <b-col class="col-auto align-self-end">&nbsp;.&nbsp;</b-col>
  <div class="w-100 pt-2 d-sm-none"></div><!-- This is a helper class -->
  <b-col class="col-3 col-sm-2 col-md-1">
    <b-form-input type="text" maxlength="3"></b-form-input>
  </b-col>
  <b-col class="col-auto align-self-center">&nbsp;-&nbsp;</b-col>
  <b-col class="col-3 col-sm-2 col-md-1">
    <b-form-input type="text" maxlength="4"></b-form-input>
  </b-col>
  <b-col class="d-block d-sm-none col-auto align-self-center">
    &nbsp;&nbsp;&nbsp;
    <!-- This is just for symmetry -->
  </b-col>
  <b-col class="col-12 col-sm-auto pt-2 pl-sm-3 pt-sm-0">
    <b-button class="btn-evm-orange">Button</b-button>
  </b-col>
</b-row>

https://jsfiddle.net/Sirence/1rspht4u/9/

Input fields will adjust their width automatically from medium devices and up.
They will be arranged in two rows for extra small and small devices.
The button is placed in a separate row for extra small and small devices.
If you prefer the layout to break at a later point, replace "md" with "sm" throughout the code.

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

When using angular.less, the @import feature is functioning correctly but a 404 error is displayed in the

Currently, I am working on a project using AngularJS along with angular.less. To centralize all my constants, I have stored them in one .less file and imported it at the beginning of all my other less files using a relative path: @import "constants" Even ...

Flask not serving Favicon and images to a React application

I am currently working with a Flask server and have it set up in the following manner: app = Flask(__name__, static_folder="dist/assets", static_url_path='/assets', template_folder="dist") ...

The HR tag does not display anything following the mailing

Struggling to design a newsletter template with different lines for each product using the HR tag. However, none of my attempts with divs, tables, or CSS properties have been successful. The template looks fine in Chrome, but when sent to the provider, th ...

What is causing the compatibility issue between Ant Design V5 styles and NextJS?

Description In my NextJS project, I am using the Ant Design V5 framework with multiple pages. However, I am facing an issue where the styles are only working correctly on one page and not being applied properly on other pages. Despite referring to the off ...

"Including Span icons, glyphs, or graphs within a table cell in AngularJS based on a specified condition or numerical

I'm attempting to incorporate span icons/glyph-icons using Angular within a td before displaying the country. I've utilized the code below to achieve this, but I'm looking for a more dynamic and elegant solution. Your assistance is greatly a ...

Setting a div's width to cover 100% of the screen's width

I'm currently working on creating a 2 column layout using divs. The left column has a fixed size of 150 px, while the right column should extend to the right boundary of the browser. I've tried using both width:auto and width:100% values for the ...

A step-by-step guide on how to display a specified amount of images in the center of

I'm currently working with a div that displays images dynamically loaded from a database, ranging from 1 to 5 images. The number of images may vary each time, and I need assistance in centering these images inside the div regardless of their quantity. ...

Javascript postback functionality is fully operational in bootstrap 4, however, it is failing to return

Encountering an issue with my postback JavaScript function in the ASP/BootStrap environment. After searching on stackoverflow for a solution, I couldn't find one that resolved my problem. The problem is when I click on an image, the page reloads (the ...

Can JavaScript be Utilized to Create Dynamic Layouts Successfully?

Are you curious about the viability of using Javascript to create fluid website layouts? While it is possible, how does it compare in terms of performance and complexity when compared to other methods like CSS3/HTML5? Take a look at the function below that ...

Exploring the mechanics of aligning a div using Bootstrap 4

I recently found a code snippet that beautifully centers a login box, which I implemented. However, I realized that I actually wanted the login box to be positioned 25% from the left instead of 50%. The interesting part is, the code doesn't follow the ...

Is the input box failing to show up on your screen?

I recently tackled the task of creating a commenting feature for RSS articles Throughout my journey with PHP coding, I encountered an issue where the input box for comments was not displaying. https://i.stack.imgur.com/gJIlu.png Check out the snippet fr ...

Send a MySQL query and an HTTP request to an SMS gateway through JavaScript

I have a scenario where data is being received by my confirm.php file. In this file, I have the following code and currently facing an issue with the javascript part. Any help and suggestions would be greatly appreciated. The objective of my javascript is ...

Make the div disappear after a specified time

Does anyone know of a code snippet that can make a couple of div elements fade out after a specific time period? Currently, I have the following example: <div id="CoverPop-cover" class="splash"> <div id="CoverPop-content" class="splash-center"> ...

Is there a way to change the URL in the address bar without refreshing the page?

Is it possible to update the URL in the address bar without reloading the page? I came across 2 potential solutions: Option 1: Check out this link It involves using window.history.replaceState. But when I tried implementing it in my angularjs projec ...

The intricate procedure behind applying a blur effect using CSS3 filters

MDN documentation explains that the filter blur function applies a Gaussian blur to the input image. After comparing it with OpenCV's GaussianBlur, I noticed that their effects are not identical. I am looking to achieve a similar effect using CSS3&ap ...

The dropdown feature appears to be malfunctioning in my ReactJS Bootstrap project

I'm currently working with reactJS and Bootstrap. I am attempting to display a user image with a dropdown menu, where the dropdown will open when the user clicks on it. Unfortunately, my dropdown is not functioning as expected. Below is the code sni ...

Scrolling to specific ID scrolls only in a downward direction

I have been using fullpage.js for my website and I am facing an issue. When I create a link and connect it to an id, everything works perfectly. However, I am unable to scroll back up once I have scrolled down. Here is the HTML code: <a href="#section ...

Can anyone explain the strange hexagonal substance that appeared in my POST to an InMagic Textworks system?

Upon reviewing the POST request details on an Inmagic TextWorks system in Chrome developer tools, I discovered the following while delving into the POST: Form Data view source URL encoded status: mode:sort currentPage:1 querySql:[PROCESSED]c:5f:2:61:58:-6 ...

When the source file is located in other directories, gcovr fails to generate a comprehensive report

I'm having trouble getting the correct HTML output from gcovr when the source file is located relative to my root directory. Let me illustrate with two cases where gcovr works and where it encounters issues: CASE:1 - Successful execution of gcovr Af ...

Encountered an error 'Unexpected token ;' while attempting to include a PHP variable in a jQuery AJAX call

Trying to execute a PHP script that updates a deleted field in the database when you drag a specific text element to a droppable area. Currently, here is the droppable area code: <div class="dropbin" id="dropbin" > <span class="fa fa-trash-o ...