What is the best way to ensure that the input areas stretch all the way to the edge of the screen?

This form is structured similar to Bootstrap:

HTML:

<div class="container">
  <div class="row">
    <div class="form-group row-group">
      <label class="col-6">First name</label>
      <input class="col-6" type="text" value=""></input>
    </div>
    <div class="form-group row-group">
      <label class="col-6">Last name</label>
      <input class="col-6" type="text" value=""></input>
    </div>
  </div>
  <div class="row">
    <div class="form-group row-group">
      <label class="col-4">Message</label>
      <input class="col-8" type="text" value=""></input>
    </div>
  </div>
  <div class="row">
    <div class="form-group row-group">
      <label class="col-4">Message</label>
      <input class="col-12" type="text" value=""></input>
    </div>
    <div class="form-group row-group">
      <label class="col-4">Message</label>
      <input class="col-12" type="text" value=""></input>
    </div>
    <div class="form-group row-group">
      <label class="col-4">Message</label>
      <input class="col-12" type="text" value=""></input>
    </div>
  </div>
  <div class="row">
    <div class="col-12 row-group">
      <button class="btn">Submit</button>
    </div>
  </div>
</div>

CSS:

.row {
  display: flex
}

.row-group {
  display: flex;
  flex-direction: row !important;
  align-items: center;

  label {
    flex: 0 0 100px;
  }

  input {
    flex: 1;
  }
}

.form-group {
  flex: 1 0 0;
  flex-direction: column;
}

Here is the outcome:

I am looking to extend the inputs in the first and third rows to the end of the container div without stacking horizontally with their neighbors.

I attempted this solution:

.row-group {
  input: flex: 1 1 100%;
}

However, no changes occurred.

What would be the correct method to achieve this?

Answer №1

Have a look at this Fiddle - does it match your desired outcome? https://jsfiddle.net/jspruance/1p739t1h/

Check out the revised CSS below:

.row {
  xdisplay: flex;
}

.row-group {
  display: flex;
  flex-direction: row !important;
  align-items: center;
}

  label {
    flex: 0 0 100px;
  }

  input {
    width: 100%;
    box-sizing: border-box;
    flex: 1;
  }

.form-group {
  flex: 1 0 0;
  flex-direction: column;
}

I made some adjustments to the CSS: 1) Removed extra closing bracket after the input element 2) Added missing bracket after .row-group 3) Included 'width: 100%' property and 'box-sizing: border-box' 4) Floated label to the left 5) Commented out 'display: flex' on .row as it was unnecessary

Hopefully, these changes address your concerns.

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

Is there a way to use a media query on a div element to check for the presence of a scroll bar?

A div has been styled with overflow-y: auto, triggering the appearance of a vertical scroll bar when the content exceeds the height of the div. This causes the content to shift horizontally to accommodate the scroll bar, resulting in misalignment with the ...

Issue with function operation

Incorporating HTML code with Angular elements on the homepage of a PHP forum script has been challenging. I have inserted the PHP code into index.template.php as instructed, but unfortunately, nothing is being displayed. <?php /** * This function ...

How can I delete an individual HTML element that does not have a class or ID?

I am currently working with a theme that cannot be altered due to automatic update requirements. The theme includes the following HTML code snippet: <div class="dropdown-menu"> <a href="#">Profile</a> | <a href="#">Logout</a> ...

What is the best way to center these icons vertically in my navigation menu using CSS?

My website has a navigation menu with third-party icon libraries (Material/FontAwesome) in use. I am facing an issue where the icons are not aligning vertically with the anchor text. Adjusting the font size of the icon to match the text results in it appe ...

Enhance Your jQuery Skills by Adding Custom Directories to Anchor Links

Can jQuery be used to add a custom folder name in front of all links on a webpage? For example, if the website has these links: <a href="/user/login">Login</a> <a href="/user/register">Register</a> <a href="/user/forum">Foru ...

Issue with thymeleaf causing malfunction in top-bar navigation on foundation framework

Looking for advice on creating a navigable menu using Foundation's "top-bar" component in an HTML template file with Spring MVC + thymeleaf. The menu bar appears but the sub-menus are not displaying when hovering over them. Sub-menus related to main ...

Sequentially iterate through elements based on their Data attributes

Assume you are working with HTML elements like the ones shown below <span class="active" data-id="3"> Test 3 </span> <span class="active" data-id="1"> Test 1 </span> <span class="activ ...

Assign a CSS class to a DIV depending on the vertical position of the cursor

The website I am currently developing is located at Within the site, there is a collection of project titles. When hovering over a project title, the featured image is displayed directly below it. I would like to change the positioning of these images to ...

What is the best way to eliminate spaces when moving to a new line in HTML?

How can I eliminate the gap between the first and second images in HTML when changing lines? <div> <img src='http://lorempixel.com/100/100/abstract/1' /> <img src='http://lorempixel.com/100/100/abstract/2' />< ...

Enhancing image search functionality through dynamic HTML updates

I need help figuring out how to update the link address for profile pictures on my NHL stats website. Currently, I am using a script to append the image to the body, but I don't know how to properly add the player ID ({{p1_ID}}) to the link and includ ...

Need assistance with PHP syntax?

Can you guide me on the correct syntax for creating a target link for a profile? <a href="index.php?p=profile&uid=<?php echo $_SESSION["uid"]; ?>"> <?php echo $_SESSION["username"]; ?></a> The variables I am working with are: ...

Images of equal height without compromising the resolution

How can I create responsive images with the same height inside a DIV tag, with a specified height of 200px? Any assistance would be greatly appreciated. <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="desc ...

Legend alignment issue in Firefox disrupting Flexbox functionality

My fieldset has a legend containing text and a button. I am attempting to use flexbox to right-align the button within the legend. This setup works correctly in Chrome, but encounters issues in Firefox. I have managed to replicate the problem with a simpl ...

Can a custom structural directive be utilized under certain circumstances within Angular?

Presently, I am working with a unique custom structural directive that looks like this: <div *someDirective>. This specific directive displays a div only when certain conditions are met. However, I am faced with the challenge of implementing condit ...

Tips for reducing text in a card design

As a newcomer to codeigniter 4, I recently created an event card with a lengthy description. However, when I attempted to display the event data from the database on the card, it ended up becoming elongated due to the length of the description: https://i. ...

How about this: "Designing a Pop-Up Window

Currently working on my own customized modal, here's the unique CSS I came up with: .custom-modal{ position: absolute; display: block; top: 0; left: 0; width: 100%; height: 100%; background-color: #000; filter:alpha(o ...

Ways to turn off hover highlighting

Is there a way to disable the highlighting effect of the <select> element in HTML? When you hover over items in the dropdown list, a blue color strip moves with your mouse. I need to find a way to get rid of this effect. Here is an example of the c ...

Adjusting the height of a table column to accommodate lengthy text without disrupting the layout of adjacent columns

I am encountering an issue while creating an invoice using an HTML table. The problem arises when the customer address value is too long, causing the sold by column to shift downwards. I need a way to break the customer address value when it reaches the ma ...

Deactivate Link Using CSS while Allowing Title to be Functional

Is there a way to enable the link in CSS while still showing the title? Take a look at my code: CSS and HTML Code: .disabledLink { pointer-events: none; opacity: 0.6; cursor: default; } <a href="www.google.com" class="disableLink" title="M ...

space allocated beneath a table cell

I am currently utilizing the foundation framework for emails and have encountered a formatting issue on my Test Page. There seems to be an unwanted whitespace just below the racoon image that I am struggling to remove. Despite setting the height to 250px, ...