Ensure that the input box expands to occupy the entire HTML page

After reviewing numerous pages and questions related to this topic, I have located the correct solution but am struggling to implement it. My goal is to achieve a similar outcome to the second question, but I'm having difficulty figuring out how to do so. Style input element to fill remaining width of its container

The issue I'm encountering is that all the input elements only stretch as far as the end of the form section. I suspect that the problem lies with the form itself rather than the input boxes. How can I ensure that the form extends to the width of its parent? Below is the full code for reference.

<style>

div.modal-header{background-color: #1A2930; color: white; }
div.modal-footer{ background-color: #1A2930; color: white; }

div.modal-body{ background-color: #F0F0F0;  color: #0A1612; width: 100%; }
div.movement-modal-form{ width: 100%; }

label
{
float: left;
font-size: 20px
}
span{
display: block;
overflow: hidden;
width: 100%
}

input
{
background-color: #C5C1C0; 
border: solid 2px #0A1612;
color: black;
width: 100%;
height: 25px; 
font-size:12px; 
vertical-align:0px
}
textarea
{
background-color: #C5C1C0;
border: solid 2px #0A1612;
width : 100%
}

</style>

<div id="movement-modal" class="modal fade" role="dialog">
<div class="modal-dialog">
<div class="modal-content">

  <div class="modal-header">
    <button type="button" class="close" data-dismiss="modal">&#x274C;  </button>
    <h4 id="modal-title" class="modal-title">{{#i18n}}inventory.modify.button.new-movement{{/i18n}}</h4>
  </div>

  <div class="modal-body">
    <form id="movement-modal-form"
    >
      {{>inventory/partials/movement-id-field-modal}}
      {{>inventory/partials/product-fields-modal}}
      <br/>
      <p>
      <!--This is #4--> 

            <label id="movement-lable"  for="movement-date">{{#i18n}}inventory.modify.table.movement-date{{/i18n}}</label>&nbsp;
            <input id="movement-date" class="movement-date" type="date" required>
      </p>
      <br/>
      <p>
      <!--This is #5-->
            <label for="store-from">{{#i18n}}inventory.modify.table.store-from{{/i18n}}</label>&nbsp;
            <br/>
            <br/>
            <select id="store-from" class="store-from"required>
                {{#inventoryStoreList}}
                    <option value={{ id }}>{{ name }}</option>
                {{/inventoryStoreList}}
        </select>
      </p>
      <br/>
      <p>

      <!--this is # 6-->
            <label for="store-from-current-quantity">{{#i18n}}inventory.movement.modal.store-from-current-quantity{{/i18n}}</label>&nbsp;
            <input id="store-from-current-quantity" class="store-from-current-quantity" type="text" disabled>
      </p>
      <br/>
      <p>

      <!--This is # 7-->
            <label for="store-to">{{#i18n}}inventory.modify.table.store-to{{/i18n}}</label>&nbsp;
            <select id="store-to" class="store-to" required>
                {{#inventoryStoreList}}
                    <option value={{ id }}>{{ name }}</option>
                {{/inventoryStoreList}}
            </select>
      </p>
      <br/>
      <p>
      <!--8-->
            <label for="store-to-current-quantity">{{#i18n}}inventory.movement.modal.store-to-current-quantity{{/i18n}}</label>&nbsp;
            <input id="store-to-current-quantity" class="product-current-quantity" type="text" disabled>
      </p>
      <br/>
      <p>
      <!--9-->
            <label for="movement-quantity">{{#i18n}}inventory.modify.table.quantity-requested{{/i18n}}</label>&nbsp;
            <input id="movement-quantity" class="movement-quantity" type="number" step="1" min="1" pattern="\d*" required>
      </p>
      <br/>
      <!--10 Notes-->
      {{>inventory/partials/note-field-modal}}
      <input type="submit" style="display: none">
    </form>
  </div>


  <div class="modal-footer">
    <button type="button" class="btn btn-danger" data-dismiss="modal" style="float: left">{{#i18n}}inventory.modify.button.cancel{{/i18n}}</button>
    <button id="movement-modal-submit" type="button" class="btn btn-success" style="float: right">{{#i18n}}inventory.movement.modal.button.save{{/i18n}}</button>
  </div>
</div>

Answer №1

It appears that the width of your modal-body is not behaving as expected. It seems like you are aiming to make the input match the width of the modal-body, but there may be some confusion in your question.

If you want the input to take up the full width of the modal-body, you can simply set the width of the movement-date class to 100%. This will ensure that the input element spans the entire width of its parent element, which in this case is the modal-body.


div.modal-body{
   background-color: white;
   color: black;
   margin: 20px 0;
   padding: 15px;
   width: 500px;
   overflow: hidden;
 }

 input.movement-date {
   background-color: lightgray; 
   border: solid 2px #6E6E6E;
   width: 100%;
   height: 25px; 
   font-size: 12px; 
   vertical-align: 0px;
}


<div class="modal-body">
    <form id="movement-modal-form">
      <p>
         <label id="movement-lable" for="movement-date"></label>
         <input id="movement-date" class="movement-date" type="date" required />
     </p>
   </form>
</div>

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

What is the best way to eliminate all borders from a select box?

Is there a way to completely remove all borders from the selectbox using either CSS or JQuery? The code snippet is as follows: <select id="doctor_ch"> <option value="1" selected>One</option> <option value="2">Two</option& ...

Unveiling the secret to accessing properties using v-if within a custom component template relocation

I'm currently working on an application that reveals a hidden div when the text "Create Test" is clicked. Everything works well when the code isn't placed inside the template of a component. This seems strange to me, what could be causing this is ...

Exemplary CSS Text Alignment When Vertical Align is Exceptional

I'm currently working on a menu where some text needs to be aligned vertically with the property vertical-align:super. However, I am facing an issue where this particular item with "super" text is not aligning properly with the other items. Below is ...

How can we incorporate Django template tags into our jQuery/JavaScript code?

Is it possible to incorporate Django's template tags within JavaScript code? For example, utilizing {% form.as_p %} in jQuery to dynamically inject forms onto the webpage. ...

Building a Next.js project encounters issues with the <img> HTML tag

Lately, I've dived into creating websites using Next.js and have been experimenting with a combination of Image and img for different purposes. I am aware that Image is an integral part of Next.js and the preferred option, but there are instances whe ...

Can anyone tell me the method to retrieve the id of the current element that initiated the horizonSwiper event in JavaScript?

I successfully integrated horizonSwiper into my php(Yii2) website to display images from different albums in a horizontal row with the ability to scroll left and right. Now, I am looking to implement lazy loading when scrolling or swiping left/right. Howev ...

The MongoDB query isn't functioning properly as the Match operation is returning an array with no elements

I am currently facing an issue with creating an aggregation pipeline. Everything seems to be working fine in the code until it reaches the $match section, which returns nothing. Here is the snippet of my code: var userId = req.params.UserId const m ...

Any tips on how to personalize the loading animation for single pages using CSS and GIFs?

presentLoading(message) { this.loading = this.loadingCtrl.create({ dismissOnPageChange: false, spinner:'hide', content:`<img class="load" src="assets/dual.gif" />`, }); this.loading.present(); } Hello there! I am working with the ...

What is the best way to trigger a Quasar dialog from an outside component?

Currently, I am working with Vue.js 2.x + Quasar 1.x using http-vue-loader (no build tools required). I have placed a q-dialog in a separate component named MyComponent. However, when I try to include it in a parent component like this: <my-component&g ...

Guide on executing a Python script using Node.js

I have set up a node.js server on Raspberry Pi and encountered an issue when trying to run a python script from it. Despite receiving the correct output from the client, the file fails to execute in this instance involving socket.io. The socket functiona ...

Change the class of multiple elements using jQuery with a set time interval

Here is a clever jQuery snippet I've put together to toggle the class of an element at intervals: setInterval(function(){$('.grid-item .slide-image').toggleClass('active')}, 800); The code runs smoothly! However, I now have multi ...

Issues with retrieving the scope attribute within a directive

I am currently facing an issue where I am unable to access the values stored in $scope.photoRes within my directive. When I use console.log(scope.photoRes) in the directive, it only displays an empty object. Here is the output from the console: Object {fi ...

The Unit Test for Angular NgRx is not passing as expected

I'm facing difficulties with my unit tests failing. How can I verify that my asynchronous condition is met after a store dispatch? There are 3 specific checks I want to perform: 1/ Ensure that my component is truthy after the dispatch (when the cond ...

Issue locating the bottom of the scroll bar

My attempt to detect when the scroll reaches the bottom of a div involves using this code: $('.scrollpane').scroll(function(){ if ($(this).scrollTop() + $(this).height() === $("#results").height()) { alert('scroll at bottom&a ...

The Bootstrap grid is not aligning to the center when dynamically adjusting sizes

I am currently in the process of developing a store website using bootstrap. One issue I am facing involves creating a grid for my product display. The problem is that the number of grid cells remains constant even when the screen size is reduced. I would ...

The list countdown for loop only appears in the initial iteration

Hey there, I'm currently facing an issue with duplicating my JavaScript countdowns and displaying images of cards on each loop iteration. Strangely, the countdown only appears in the first instance even though it's within the loop. I'm seeki ...

Angular-ui-bootstrap modal failing to display provided data

I have been working on implementing model data into a modal window that opens. The data is passed through a $http.post success and also in failure then() with different titles and button texts. Several data points are being passed to the modal: //.then(){ ...

Using async/await in a for loop | The await keyword can only be used inside an asynchronous function

I've been attempting to execute the following code: async function verifyExistingUsers(db, users) { return new Promise((resolve, reject) => { var companies = [] for (const [index, user] of users.entries()) { let comp ...

Error: The fetch request was unsuccessful [NextJS API]

I keep encountering an error - TypeError: fetch failed after waiting for 300 seconds while requesting an optimization server that requires a response time longer than 300 seconds. The request is being sent from the provided API in NextJS. Is there a way ...

Displaying and hiding the Angular <object> element

I am faced with a challenge involving managing files of various formats and creating a gallery with preview functionality. Everything works smoothly when clicking through items of the same format, like JPEGs. However, an issue arises when switching from vi ...