The consistency of the input box is lacking

Why is my input box not consistent? Every time I add it, the width increases. I understand it's because of the 'col' control but it's creating a messy layout as shown in the image below

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

This is the code I'm using:

I am using CSS with

.flex{
      display: flex;
 }

I want the symbol to stay beside the input field, but they are getting combined. Is there a way to make the input box consistent?

const $container = $('#contactContainer')
$(".remove").eq(0).hide()
$container.on('click', ".ar", function(e) {
  const add = $(this).is(".add");
  const $phones = $container.find(".phone");
  const len = $phones.length;
  if (add) {
    const $newPhone = $phones.eq(0).clone(true)
    $newPhone.find("[name=contact]")
      .attr("id", `new_${$phones.length}`)
      .val("");
    $container.append($newPhone);
    $newPhone.find(".add").remove()
    $newPhone.find(".remove").show()
  } else {
    $(this).closest(".phone").remove()
  }

})
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="31535e5e45424543504171041f011f03">[email protected]</a>/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<div class="form-group row">
  <label for="contact" class="col-2 col-form-label">Contact:</label>
  <style>
  .flex{ display: flex; }
  </style>
  <div class="col-4" id="contactContainer">
    <div class="flex phone" style="margin-bottom:5px;">
      <input style="margin-right: 10px;" id="validationcontact" name="contact" type="text" class="form-control" pattern="\b\d{8}\b" required>
      <input type="button" class="ar add" value="Add more field!" style="cursor: pointer;">
      
      <span class="ar remove"><label style="cursor: pointer; padding-top: 5px;"><i data-feather="minus">-</i></label></span>

    </div>

  </div>
</div>

Answer №1

Find the answer with a straightforward approach by setting the width through style

Style="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

Could the Error Detected by Siteimprove Regarding WAI-ARIA Criterion 1.3.1 be a Mistake?

When using the Siteimprove extension v. 126 for Chrome, the following HTML snippets are all showing an issue labeled "Input field has no description 1.3.1" Some may argue that a description is unnecessary because the aria-hidden attribute should effective ...

Updating Object Properties in Angular 6 without Explicitly Setting Them

In my editor, users can modify product details. To allow for resetting these edits, I store the initial product instance in ngOnInit as initialProduct. However, I've encountered a strange problem: When adding a new tag, the properties of initialProdu ...

The assets path is the directory within the installed package that houses the main application files following the completion of a

I have a Vue.js UI component that is internally built using webpack. This reusable UI component library references its images as shown below: <img src="./assets/logo.png"/> <img src="./assets/edit-icon.svg"/>   <i ...

Dynamic links with Node Acl

Utilizing the npm module Acl to establish an ACL system has been my current focus. You can check out the homepage of this module at: https://github.com/OptimalBits/node_acl. While the documentation provides straightforward examples for granting role acces ...

When integrating external HTML into an Angular 2 component, relative references may become invalid and fail to

My server hosts basic HTML content that includes an image with a relative file location. While this displays correctly in a browser, loading the content using Angular causes issues with resolving the relative path locally. I have tried following suggestio ...

The useRoutes function is returning null despite the correct pathname being provided

Check out my React code snippet! I've got the Component nestled within a micro-frontend application, which is then brought into the main app using module federation. // embedded in my microfrontend. const path = '/another-component-path'; f ...

Transforming a callback function into a Promise: A step-by-step guide

I'm currently utilizing Bluebird promises and attempting to make the following function work with Promisify: var jwt = require('jsonwebtoken'); function _test_encode() { var cert = fs.readFileSync('public.pub'); return j ...

What is the best way to incorporate Amazon AWS's client JavaScript into my Ionic 2/Angular 2 application?

I am currently working on a project using Angular 2/Ionic2 that relies on a custom client api provided by Amazon AWS. The api is composed of a main javascript file and other dependent scripts. Traditionally, I would include these scripts in the HTML file ...

Trouble with custom font updates in Hugo using Blogdown

Recently, I've been immersing myself in Blogdown to create my own personal data blog: Using the academic theme as a base, I successfully tweaked the color scheme without any hiccups. However, despite making adjustments in my params.yaml file, none o ...

Using identical CSS styles across various classes in material UI

Three classes have been defined with identical CSS properties. const useStyles = makeStyles((theme) => ({ classA: { color: 'green' }, classB: { color: 'green' }, classC: { color: 'green' } }) Is there a way to combin ...

What could be the reason that a MUI component does not disappear when the display is set to none in the sx prop?

I'm attempting to construct a responsive side drawer using MUI's Drawer component in React, specifically leveraging MUI version 4.12.1. In the example provided on the mui.com website, they utilize the sx prop and pass an object with different di ...

I am looking to adjust the width of an element within an Iframe

In my single post, I have a social sidebar on the left side. Currently, the buttons in the sidebar are appearing in different sizes, but I want them all to be the same size as the "Twitter" button. To see the issue, please visit this link. I've tried ...

"An issue with geolocation is causing it to be unable to locate

Incorporated a map into my AngularJS/Ionic application using geolocation with a "find me" feature designed to identify our location on the map. However, encountering issues in implementing this functionality - the progress circle displays but fails to pinp ...

Switching from using jQuery.ajax() to fetch() when making requests to a Go REST API endpoint with no payload

I have a ReactJS web application that communicates with a REST API endpoint built in golang. Previously, I used jQuery to make Ajax POST requests and it worked perfectly. Here's an example of the code: // Using jQuery let sendUrl = "http://192.168.1 ...

Record the success or failure of a Protractor test case to generate customized reports

Recently, I implemented Protractor testing for our Angular apps at the company and I've been searching for a straightforward method to record the pass/fail status of each scenario in the spec classes. Is there a simple solution for this? Despite my at ...

The justify-content property is failing to properly align content along the main axis in Grid layout

I've implemented tailwind for my CSS styling. Within a simple div, I have 3 child elements. My goal is to create space between them along the main axis. Here's the code snippet in question: <div className="grid grid-cols-12 text-white ju ...

My header has a video background that appears aesthetically pleasing on a desktop screen. However, when viewed on a mobile device, it is off-center and doesn't span the full

I am having an issue with a header that has a video background. It looks great on desktop, but on mobile devices, it is only taking up about 2/3 of the screen width and is aligned to the left side instead of filling the entire width. I have tried several ...

Struggling with Bootstrap 4 modal functionality on mobile devices? Unable to close the modal or see its contents properly?

Attempting to incorporate the Bootstrap 4 modal into a block results in an incorrect display. The modal appears in a "fade in" mode and becomes unresponsive, making it impossible to close the modal without refreshing the browser. <div class="modal fade ...

Unexpected behavior: Axios post still enters catch block despite successful completion of Rest API call

Having an issue with my axios post request not returning the value from the API in a non-success scenario (401 error). It works fine for successful scenarios. When using Postman to test the output of my reset password API by providing an incorrect current ...

Clicking on the breadcrumb separator

My objective is to present hierarchical data using the bootstrap breadcrumb component. Specifically, upon clicking the separator symbol >, I aim to showcase a dropdown list containing the siblings - akin to the interface in Windows Explorer when navigat ...