Eliminate excess spacing to the right of input fields

I've been attempting to configure a flexbox layout with multiple input fields, but I'm having trouble achieving the desired look. Here is the code snippet that I've been working with:

.inputSettings {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  max-width: 750px;
}

.inputSettings > form {
  background: red;
  border: 1px solid yellow;
  flex: 1;
}

.inputSettings > form > input {
  width: 165px;
  height: 30px;
  border-radius: 5px;
}
<div class="inputSettings">
  <form>
    <label>First Name</label>
    <input type="text" id="fname" name="fname">
  </form>
  <form>
    <label>First Name</label>
    <input type="text" id="fname" name="fname">
  </form>
  <form>
    <label>First Name</label>
    <input type="text" id="fname" name="fname">
  </form>
  <form>
    <label>First Name</label>
    <input type="text" id="fname" name="fname">
  </form>
  <form>
    <label>First Name</label>
    <input type="text" id="fname" name="fname">
  </form>
  <form>
    <label>First Name</label>
    <input type="text" id="fname" name="fname">
  </form>
</div>

JSfiddle: https://jsfiddle.net/rz94hwbv/2/

I am aiming to evenly space the input fields inside the flexbox so that the leftmost input field's border aligns with the left border of the box, and the rightmost input field's border aligns with the rightmost border. Currently, there is some padding to the right of each input field. I've tried various approaches without success. Any assistance or suggestions would be greatly appreciated.

Answer №1

One issue that stands out to me is the use of flex:1; in comparison to the limited width of the

.inputSettings > form > input
. To ensure that the fields reach the sides, it is necessary for the inputs to have flexible expansion.

.inputSettings {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  max-width: 850px;
  border-right: 12px solid purple;
}

.inputSettings > form {
  background: red;
  border: 1px solid yellow;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.inputSettings > form > input {
    border-radius: 5px;
}
<div class="inputSettings">
<form>
  <label>First Name</label>
  <input type="text" id="fname" name="fname">
</form>

<form>
  <label>First Name</label>
  <input type="text" id="fname" name="fname">
</form>
  
  <form>
  <label>First Name</label>
  <input type="text" id="fname" name="fname">
</form>
  
  <form>
  <label>First Name</label>
  <input type="text" id="fname" name="fname">
</form>
  
  <form>
  <label>First Name</label>
  <input type="text" id="fname" name="fname">
</form>
  
  <form>
  <label>First Name</label>
  <input type="text" id="fname" name="fname">
</form>
  
  <form>
  <label>First Name</label>
  <input type="text" id="fname" name="fname">
</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 reason for my website page topic being positioned behind the navbar in Bootstrap?

When I click on the navbar, I expect to see the topic displayed beside it, but instead, it is appearing below the navbar. I've tried adding margins, but that hasn't resolved the issue. Can someone help me with finding a solution? This is how my ...

Pause animation when hovering over their current positions

I am working on a project with two separate divs, each containing a circle and a smiley face. The innercircle1 div is currently rotating with a predefined animation. My goal is to create an effect where hovering over the innercircle1 div will pause its rot ...

Calculate the total sum of values in a MySQL column and then group the results

I'm currently working on a quiz website and looking to create a leaderboard. The user scores are stored in a database table named 'user_record' with the following structure: 'user_id' - varchar(254) -holds the user id for a score ...

What is the process for calling a class in HTML from a <Div> tag?

I am struggling with the following code snippet: <p class=‘majed’ style="color:#FF0000";>Red paragraph text</p> How can I reference the 'majed' class above? <Div class=‘majed’ > </Div> Your help is greatly appr ...

The iframe is not adjusting its size in relation to the parent window

For more information, click here: http://jsfiddle.net/5HYve/ <div style="position: fixed; top:0; right:0; width:300px; height: 100%; text-align:justify; overflow:hidden;" class="chat-container"> <iframe id="chat_1" style="width:300px;height:1 ...

Utilizing the power of HTML5 drag and drop functionality in conjunction with Angular Material 2's md

When working with Angular Material 2 and attempting to enable reordering of list elements, I encountered an issue where the functionality works perfectly for li-tag but fails with md-list-item. Why is that? Here is a snippet of my template: <md-nav-li ...

Maintain the alignment of content in the center while expanding background images

I am looking to create a website with a split background effect, similar to the design on this site . I want to maintain a content container width of 980px while achieving this look. I attempted to accomplish this by adding height and background color pro ...

Explanation on subtracting the row value from a textbox

Click here to view the image For instance: If I enter a value in the "USED(kl)" textbox, it should subtract that value from the corresponding row where "KILOGRAM/S" is located; Upon clicking the update button, only the specific row should be affected wh ...

I am seeing an empty dynamic HTML table

I have been working on creating a dynamic HTML table, but I am facing an issue where the data is not displaying in the table. I have verified that the query is correct by testing it in SQL and confirming that it outputs the data. The problem seems to lie w ...

Show divs in identical position when clicking

There are 4 section divs that need to be displayed in the center of the page when clicked, but the last one appears further down. This is likely due to the flex box nature. What is the best way to ensure all sections appear at the exact same location? Ano ...

Issue with the functionality of max-height in a CSS grid container

Update: After receiving clarification from @onkar-ruikar, I realized that my original problem was quite misunderstood. While I still haven't figured out how to properly handle the cyclic dependencies issue, I decided to address it separately. As a res ...

"Utilize Bootstrap Flexbox for centering and aligning

I'm having trouble centering my navigation items and positioning my button at the end. I was able to move the button to the end, but I can't seem to figure out how to center the items and brand. Any assistance would be greatly appreciated! < ...

Is there a way to position the image at the exact center of the column?

Currently, I am attempting to design a container that includes an image on the left, a title and description in the center, and a button on the right. However, I am facing difficulties centering the image in the first column and the button in the last colu ...

The issue with Angular 2's Parameterised router link component not fully refreshing

I'm trying to figure out how to show a set of images when I click on a specific menu item. The menu structure looks like this: <ul id="demo23" class="collapse"> <li> <a [routerLink]="['image-gallery','Picasso ...

What could be the reason for the absence of a second alert appearing?

I have a small application that validates email addresses for the correct elements, but it's not displaying the confirmation message. $(document).ready(function(){ $("#sendButton").click(function(){ var name = $("#name").val(); ...

Activate just the show more / show less button on the website that has several buttons with identical ids

Whenever the "show more" button is clicked, additional images are displayed in the gallery and the button text changes to "show less". However, in my ExpressionEngine (CMS) templates and entries, all "show more" buttons share the same id, causing other but ...

Tips for incorporating a theme into your CSS code using BEM naming conventions

Currently, I am using the BEM CSS naming convention for a project I am currently working on. So far, everything is going smoothly. However, I am faced with the challenge of implementing multiple themes (each with slightly different designs) on the same HTM ...

When adding a new div, ensure it is counted and delete it once a new div is added

When clicked, a new div is added. When clicked again, another div with the same content is created as a duplicate. Q: Is there a way to remove the previous div when a new one is created? $(document).on('click', '.LibSectOpen', functio ...

Verify if the specified value is present in the dropdown using AngularJS

Utilizing AngularJS, I have implemented an input field with autocomplete functionality. The autocomplete feature pulls data from a JSON file and displays it in a dropdown table format. Users are able to filter the results and select a value from the dropdo ...

Tips for customizing the CSS styling of the validation ng-class error

Seeking advice: Is there a way to customize the CSS style of the 'error' validation error for ng-class in Bootstrap v3? This is my current code: ng-class="(form.datos.$invalid) && ( form.datos.$touched || submitted) ? 'error&apos ...