``I am having difficulty with Bootstrap as it seems to be hiding my field or

I'm currently working on a webpage that uses Bootstrap. It has a form with a label and text input field.

When I add the class="custom-control-input" to the input field, Bootstrap hides it. Can someone explain why?

If I don't include the class, the input field appears but doesn't extend to the full width of its parent div tag.

Here is the code snippet:


    <div class="container">
        <form class="needs-validation" novalidate action="submit_transgene_entry.php" method="post">
            <div class="row">
                <div class="col-md-2 mb-3">
                    <label for="comments_fieldID1">This field is displayed but not full width</label>
                </div>
                <div class="col-md-10 mb-3">
                    <input type="text" id="comments_fieldID1" name="comments_fieldName">
                </div>
            </div>

            <div class="row">
                <div class="col-md-2 mb-3">
                    <label for="comments_fieldID2">The next field is hidden by custom-control-input</label>
                </div>
                <div class="col-md-4 mb-3">
                    <input type="text" id="comments_fieldID2" class="custom-control-input" name="comments_fieldName">
                </div>
            </div>

            <div class="row">
                <div class="col-md-3 mb-3">
                    <input type="submit" name='accept_transgene_entry' class="btn btn-primary btn-lg btn-block" value="Accept Transgene Entry" alt="Accept Transgene Entry"/>
                </div>
            </div>
        </form>
    </div>

To see this code in action, visit this page.

Answer №1

Make sure to utilize the form-control class in place of custom-control-input.
Check out the updated version of your code on this modified fiddle:
https://jsfiddle.net/2orbj50v/

Answer №2

To implement this style, include the following code snippet in your CSS file:

#field_ID_for_comments {
  width:100%;
}

Answer №3

The reason for hiding this element is because the class "custom-control-input" has default CSS values from Bootstrap. If you change the opacity to 1 instead of 0, it will make the original field visible.

.custom-control-input {
    position: absolute;
    z-index: -1;
    opacity: 0;
}

To ensure the input field spans the full width, apply the following CSS:

#comments_fieldID1 {
      width:100%;
    }

Answer №4

Bootstrap 4 offers customized form elements for different types:

  1. Checkbox
  2. Radio button
  3. Range
  4. Select
  5. Upload
  6. Toggle

In order for these custom elements to function properly, they must be enclosed within a <div> with the class of

class="custom-control custom-checkbox"
. For example, when using a custom checkbox:

<div class="custom-control custom-checkbox mb-3">
  <input type="checkbox" class="custom-control-input" id="customCheck" name="example1">
  <label class="custom-control-label" for="customCheck">Custom checkbox</label>
</div>

If you want your first input box to have a width of 100%, simply apply the following CSS:

#comments_fieldID1{
   width:100%;
} 

Answer №5

Top Solution : Implement the form-control class for your #comments_fieldID1 section

You also have the option to include CSS in your stylesheet:

#comments_fieldID1 {
    width:  100%;
}

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

Changing the width of an HTML table does not produce any noticeable results

I attempted to create a striped table with 5 columns. The desired column sizes are: 10% width --- 10% width --- 40% width --- 20% width --- 20% width However, my current code is not achieving the correct widths (the 'description' column does n ...

How can images be resized according to screen resolution without relying on javascript?

Looking to use a large banner image on my website with dimensions of 976X450. How can I make sure that the image stretches to fit higher resolution monitors without using multiple images for different resolutions? ...

How can I remove the excess space above and below tables that have differing numbers of rows?

Forgive me if my question seems basic or if there are any errors in it. I am new to HTML/CSS and collaboration tools like this platform. While I understand that these are not your typical HTML tables, they are what I've found to be the most effective ...

The communication factor that triggers the expansion of the mother element

I've been struggling with this issue for quite some time. Here is the challenge at hand: I am in the process of developing a library to streamline AJAX calls and neatly display error messages directly within a form. The dilemma: Whenever the messag ...

Troubles with aligning and floating three divs in the center of a container div – a CSS conundrum illustrated with code snippets and a basic diagram

I'm struggling to center 3 divs within a "container." Here's a rough idea of what I'm going for: ______________________ | ___ ___ ___ | | |___| |___| |___| | |______________________| The issue I'm facing is g ...

Conceal the title text within the collapsed sidebar in AdminLTE

When using the AdminLTE theme, I noticed that when I collapse the sidebar, the menu title gets hidden under the pull-right-container icon. See the image below for a better understanding. View Error Image Is there a way to display it on a new line? Below ...

Incorporating Google fonts into email designs

I am struggling to get Google fonts to display properly in my newsletter emails. Here is the code snippet I have been using: $html=" <html> <style> @import url(http://fonts.googleapis.com/css?family=Lato|Simonetta); </style> <body& ...

Position an element with absolute positioning to the right edge of a relative element

I have a situation where I need to align the end of a position absolute element with the end of a relative element, but the relative element's width is not fixed and may vary based on content. https://i.sstatic.net/L2sLP.jpg This scenario arises as ...

Separating stylesheets, head, and other elements in a curl response

After successfully using curl to retrieve an external site, I noticed that the results were interfering with my own content. The CSS from the external site was affecting my webpage's layout and z-index values were conflicting. I am seeking a solution ...

Conceal the PayPal Button

Currently, I'm facing a challenge where I need to dynamically show or hide a PayPal button based on the status of my switch. The issue is that once the PayPal button is displayed, it remains visible even if the switch is toggled back to credit card pa ...

Attempting to adjust table size in MPDF to fill the available height

I'm currently utilizing MPDF in order to create a PDF document from an HTML page that includes a table. My goal is to have the table expand to fill up the remaining space on the page. Here is the specific table I am working with: I want the final el ...

Having trouble with images not showing up on React applications built with webpack?

Hey there! I decided not to use the create react app command and instead built everything from scratch. Below is my webpack configuration: const path = require("path"); module.exports = { mode: "development", entry: "./index.js", output: { pa ...

Combining the elements p and div on a single line

I've designed a card layout with 3 rows containing a paragraph and a div element each. I want both elements in each row to be displayed on the same line. How can I achieve this? Sample HTML: <div class="user_card"> <div class="skills"&g ...

Troubleshooting alignment problems with CSS DIVs within VUE Components

I have a Vue application with 2 components, each housed in their own div. My CSS skills are not strong, so I found a CSS template that works well and is responsive. However, I've noticed that the top and bottom divs do not align properly and their wid ...

Display the contents of a <div> tag from one HTML file onto another HTML file

Recently I embarked on learning HTML and came across a peculiar doubt. My goal is to create a section div on the first page that changes dynamically based on the menu item clicked, rather than redirecting to another HTML page. I've experimented with s ...

There are currently no articles found that match the search query

Recently, I started working with Django, but I am facing an issue with slug. Whenever I send a request to the Slug, I encounter an error. The error message I receive is: Articles matching query does not exist. Furthermore, I am facing another error while ...

Selecting CSS tag excluding the first-child element

My goal is to use CSS to target the li elements in a list that do not have a description and are not the first-child with a b element. I want to apply padding-left to these specific li elements that do not have a title. <ul> <li><b>t ...

Utilize CSS block display for ::before and ::after pseudo elements within a div container

I have a CSS file that contains the following code snippet: .loader { width: 250px; height: 50px; line-height: 50px; text-align: center; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); font-fam ...

Tips for adjusting HTML files prior to HTMLOutput in Google Apps Script

I'm looking to make some changes to an HTML file within the doGet() function before it's output in HTMLOut. However, I'm running into an issue with the <?!=include('css').getContent();?> code snippet, as it can't be exec ...

Stop horizontal scrolling when using connected lists in full-height columns with jQuery UI Sortable

I am in the process of developing a web application that features two full-height columns utilizing Flexbox in Bootstrap v4. Each column contains a sortable list that can be rearranged using jQuery UI Sortable. HTML: <div class="container-fluid h-100 ...