The appearance of Bootstrap form input fields appear unusual

While working on a multistep form with three tabs, I encountered issues with the bootstrap styling of the input fields.

The current appearance can be seen here: (https://i.sstatic.net/1NT6e.jpg): https://i.sstatic.net/FtHRG.png

Clearly, the input fields are not rendering as expected in bootstrap. Inputting text into them causes the box to expand (as shown in the Site Name field).

I have attempted to modify the code, which is reproducible.

For those interested, my GitHub repository contains the full code for reference. (Not intended as promotion, just for code visibility).

.top-bar{

    width:100%;
    height:40px;
    background-color: #006bff;
    padding-bottom: 10px;
}
li{
    display: inline-block;
    padding: 10px;
}
.phone,.logout{
    text-align: center;
    color: #ffffff;
    text-decoration: none;
    font-size: 14px;
}
.phone:hover,.logout:hover{
    color: #F0C330;
    transition:0.5s;
}
body{
    background-color: #A6C7F0!important;
}
.logo{
    padding:20px;
}
.container{
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}
.container form{    
    background-color: #EEF1F4 !important;            /*Change Size of Box*/
    width: 900px;
    padding: 20px;
    margin: 50px;
    border-radius: 10px;
    box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
} 
.box{
    width: 800px;
}
.container table {
    background-color: #EEF1F4 !important;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
}
.link-right{
    display: flex;
    justify-content: flex-end;
}
.suggestions{
    width:98.5%;
    height:125px;
    position: relative;
    bottom:17px;
}
.container h1{
    color: #0B2D58;
    text-transform: uppercase;
    font-weight: 500;
}
<!doctype html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="...">
    <title><?= $data['title'] ?? '' ?></title>

    <!-- Bootstrap core CSS -->
    <link href="css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
    <link href="css/header.css" rel="stylesheet">
  </head>


<body>
    <div class="container">
        <!-- Form Start -->
        <form class="row g-3" id="surveyForm" action="<?= $data['action'] ?>" method="post">

            <!-- One "tab" for each step in the form: -->
            <!-- Tab 1 Start -->
                <h1>Contact & Site Details</h1>
                <!-- Row 1 Start -->
                <div class="row">
                    <div class="col-md-7">
                        <label for="site_name" class="form-label">Site Name*</label>
                        <input type="text" class="form-control" id="site_name" name="site_name"  placeholder="Enter Site Name" oninput="this.className = ''" required><br>
                    </div>

                    <div class="col-md-5">
                        <label for="poNum" class="form-label">PO Number*</label>
                        <input type="text" class="form-control" id="poNum" name="poNum"  placeholder="Enter PO Number" oninput="this.className = ''" required><br>
                    </div>

                    <div class="col-md-5">
                        <label for="customer_name" class="form-label">Contact Name*</label>
                        <input type="text" class="form-control" id="customer_name" name="customer_name"  placeholder="Enter Contact Name" oninput="this.className = ''" required>
                    </div>

                    <div class="col-md-7">
                        <label for="customer_email" class="form-label">Email Address*</label>
                        <input type="email" class="form-control" id="customer_email" name="customer_email"  placeholder="Enter Email" oninput="this.className = ''" required><br>
                    </div>

                    <div class="col-4">
                        <label for="customer_mobile" class="form-label">Contact Number*</label>
                        <input type="tel" class="form-control" id="customer_mobile" name="customer_mobile"  placeholder="Enter Contact Number" oninput="this.className = ''" required> <br>
                    </div>

                    <div class="col-8">
                        <label for="street1" class="form-label">Address*</label>
                        <input type="text" class="form-control" id="street1" name="street1"  placeholder="Address" oninput="this.className = ''" required>
                    </div>

                    <div class="col-md-5">
                        <label for="city" class="form-label">City/Town*</label>
                        <input type="text" class="form-control" id="city" name="city" placeholder="City/Town" oninput="this.className = ''" required>
                    </div>

                    <div class="col-md-5">
                        <label for="county" class="form-label">County*</label>
                        <input type="text" class="form-control" id="county" name="county"  oninput="this.className = ''" placeholder="County">
                    </div>

                    <div class="col-md-2">
                        <label for="postcode" class="form-label">Postcode*</label>
                        <input type="text" class="form-control" id="postcode" name="postcode"  placeholder="Postcode" oninput="this.className = ''" required> <br>
                    </div>
                </div>
                <!-- Row 1 End -->
            
        </form> <!--Form End -->
    </div>
</body>

</html>

Answer №1

The problem arises from the fact that you are removing all bootstrap classes on input fields.

Consider eliminating the

oninput="this.className = ''"
from all inputs to restore your form's intended appearance.

However, it begs the question - what was the original purpose of including this in the first place?

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

Retrieve a property from a designated element within the DOM

Is there a way to specifically extract the src attribute of the second image in an HTML file using PHP DOM parser? foreach($html->find('img[src]') as $element) $src = $element->getAttribute('src'); echo $src; I s ...

Is it possible for two different forms to invoke a single Javascript function?

I have a page with two separate formulas. Each formula has its own form with inputs, and both forms call the same Javascript function on key up. However, only the first formula seems to be working. I suspect that changing the structure of the JS file may ...

Issue with Angular Material Mat Horizontal Stepper: Incorrect step selection when progressing with next button

I have a horizontal mat stepper that needs to be controlled using Next and Back buttons. The steps are generated using ngFor. I have created a variable called "stepIndex" which is bound to the "selectedIndex" input. The Next button should increment this va ...

Troubles arise when trying to use Flexbox and Bootstrap for column layouts

I am struggling to properly align my team members and interests in the center and ensure the text is also centered. I want to avoid the 2 columns taking up the entire screen and I am facing challenges with wrapping the content. Ideally, I would like the 2 ...

Determining the widths of elements when floated in Opera 11.*

I'm currently facing an issue with the Opera 11.5 beta (although I suspect this applies to all Opera 11 versions) where a floated block-level element (an unordered list) is being assigned a random fixed width, causing the child elements to wrap - simi ...

Troubles with HTML, CSS, and jQuery Double-Level Menu

After creating a simplified version of an HTML, CSS, jQuery navigation menu, I noticed that the submenu items were being considered part of the containing list item. This caused them to not function as intended when clicked because they were being treated ...

How can I include a close/ok button at the bottom of a bootstrap multiselect component?

Currently, I am utilizing the Bootstrap multiselect tool to filter query outcomes on a specific page. After selecting one or multiple options, my goal is to have a "close" or "OK" button visible at the bottom of the selection list. Upon clicking this butto ...

Arranging divs in a layout similar to tables cells and rows

Currently, I am developing a small game to enhance my Javascript skills. In the past, I utilized tables for displaying my content (images): Now, my goal is to switch from using tables to divs. However, I want to position them in a manner that resembles t ...

Tips for effectively showcasing the date and time within a chat message interface

I am currently working on a chat application and have successfully implemented displaying the user's name along with the message in the chat box. However, I am facing issues with the design of the date and time display within the UI. .userTex ...

Using PHP to showcase information depending on the webpage

I am working on a website with a footer that appears on every page. I am looking for a way to dynamically change the text in the footer based on the current page the user is on. One solution I have considered is creating a session variable to track the us ...

Adding a background image in Angular is a simple process that can enhance the

Trying to add a background image to my angular application. home-component.html <body> <div style="text-align:center;" class="backgroundimage"> </div> </body> <style> * { margin: 0; ...

Dynamically create a button using jQuery and JSON based on specific conditions (either true or false)

Is there a way to generate buttons with specified parameters only if a condition is true? Currently, the buttons are generated without checking conditions. Any help with the correct syntax would be appreciated. Sample JSON code: { "Caption": "Module ...

Adjust the color of the text depending on the background it is displayed on

While practicing HTML and CSS as I normally do, I decided to work on a PSD template yesterday. Initially, it seemed straightforward, but soon I encountered the issue I'm currently facing. Specifically, I am trying to change a specific part of text ba ...

Using Javascript/JQuery to attach a javascript object to a form in order to perform a traditional form

On a page, there is a form that consists mostly of plain HTML. One section of the form creates a quite complex multidimensional object using JavaScript. Usually, if I wanted to include a variable in the POST request, I would add an <input type="hidden" ...

Integrate a feature in your form that allows users to preview and edit their submission before finalizing

I've set up my HTML form with the following structure: <div class="container"> <div class="form-group" ng-controller="studentController"> <form role="form" class="well form-horizontal" id="registerForm" name="forms.register ...

Having difficulty displaying data in the proper format with two-way binding

In the realm of my webpage, I have a plethora of headings, paragraphs, images, and other data at my disposal. From the backend, a dataset is provided to me that includes an array with various properties housing the desired information. The challenge lies i ...

Tips on toggling the visibility of a div using jQuery and CSS via a toggle switch

Hey there, I need some help with toggling the opening and closing of a div when clicking on a toggle switch. $('.tog').on('click', function() { $('.cntr').show(); }); .switch { position: relative; display: inline-bloc ...

Is there a way to use jQuery to centrally align the accordion item that I have chosen?

My attempts to use `this.scrollIntoView({behavior: "smooth"}) were yielding inconsistent results in terms of where the selected item would land on the page. I believe I might need to utilize scrollTop(), but as someone who is new to jQuery, I am ...

Mediawiki version 1.26.2 experiencing loading issues with Stylesheet

I recently updated my Mediawiki installation to the latest version 1.26.2, but I've encountered an issue with the stylesheet not loading correctly. Strangely enough, in a previous version (1.23.5) installed on the same server, everything was working f ...

React does not support having two :focus selectors on a single JSX element

I'm working with a React script that includes a specific element. I want to apply more than one :focus-within selector in CSS, but for some reason only the dropdown selector is being expressed when I focus on the element. Here's the code: React J ...