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:

https://i.sstatic.net/msV8A.png

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

distinct identifier for an HTML element that is compatible across all web browsers

Is there a specific identifier for HTML tags on a webpage? I noticed Mozilla uses uid, but is it compatible with all browsers? (I'm not concerned about IE6...) I've come across Unique identifier for HTML elements but they didn't mention t ...

create a gentle appearance for an element

I am looking to replicate the visual appearance of each page on this particular website: There is something about the lighting that I really admire. I have attempted to recreate the animation, but I have been unsuccessful in my attempts. Any assistance wo ...

Manipulating CSS animations through JQuery

Currently, my animation is triggered by a :hover event. However, I would like to change it so that the animation starts when a button is clicked. Can someone guide me on how to manipulate the CSS using JQuery? //CSS .mouth{ top: 268px; left: 273px; ...

Ways to showcase a textbox input in different DIVs multiple times

I am struggling to showcase the content of a textarea within multiple div elements when a user inputs text. The value only appears in the first div, but I want it to display in every div. Here is my HTML and jQuery code: <input type="textarea" id="my ...

Tips for adjusting custom spacing margins within Material UI Grid

Is there a way to adjust the spacing between Grid items in Material UI? Here's the code I currently have: <Grid container spacing={1}> <Grid item xs={6}>Node 1</Grid> <Grid item xs={6}>Node 2</Grid> ...and so ...

Unable to progress past first image in Bootstrap 5 carousel

I'm having trouble implementing a carousel on my HTML page. It only displays the first image, and the next and previous buttons are not functioning. I copied and pasted the code from Bootstrap directly. <link href="https://cdn.jsdelivr.net ...

CSS: Troubles with Element Widths

I'm dealing with a list item that contains an image, like so: <ul> <li> <img></img> </li> </ul> The image is not filling the entire width of the list item. Is there a way to make the list item shr ...

Is it possible to transform the Bootstrap5 sidebar, currently positioned above the block content, into a sticky element on

After creating a Django blog using bootstrap5 and following guidance from the python crash-course book, I encountered an issue with my sidebar placement. Despite trying various methods, I struggled to "override" my blocks in order to keep my sidebar fixed ...

Could anyone assist me in positioning my personalized Context Menu beside my cursor?

If possible, I would appreciate some assistance with my custom context menu. It may require some minor tweaks or a fresh idea on how to address the issue. Ideally, I would like to keep the HTML and CSS somewhat unchanged. [I'm not sure what to write ...

Positioning Images in Bootstrap 4

I'm encountering an issue with Bootstrap 4. The left box isn't aligning properly with the right box. This involves both HTML and CSS. How can I go about resolving this issue? <section> <div class="container"> <div class="row"& ...

The href attribute in a stylesheet link node is malfunctioning

When setting up my website, I experimented with two different methods. 1) The first method involved using node to run the server. 2) The second method simply used an index.html file on my local computer. Interestingly, I noticed a difference in how the s ...

Apply a red border to any form inputs that contain incorrect information when the submit

How can I add red borders to my form inputs only when they are invalid after submission, without displaying the red borders from the start? Currently, I am using the input:invalid selectors in CSS, but this causes the red borders to appear immediately. I ...

The uninterrupted execution of a server-side script is occurring without the need for

Greetings! I am currently working on a web project that combines HTML5 and Java with the Hibernate framework, utilizing AJAX as a bridge between them. My approach involves developing servlets that are connected to HTML5 forms and use AJAX to send data. Ho ...

Dynamic HTML binding with v-model in Vue JS allows for seamless two-way

I recently incorporated Vue Js into my main MVC application. I want to be able to bind a Vue Js v-model to dynamically loaded HTML from a partial view. For example, in my partial view, I have the following: <input type="text" id="firstNam ...

Website form phone number verification server

I am currently working on developing a website form where users can input their information, including their phone number. I am looking for a simple way to verify the user's phone number using PHP without the need for installation of SDKs or complex c ...

Adjusting the text color based on the dynamically set background color

If I have a calendar where each entry has a unique background color assigned to it (one color per user), including both light and dark colors that users can choose from, how can I set the text color to match the background style? Where should I begin wit ...

Automate your functions using Javascript!

Hello, I have written a code snippet that triggers an action on mouse click. Initially, I created a function that scrolls the screen to a specific element upon clicking another element: (function($) { $.fn.goTo = function() { $('html, bo ...

powerful enhancer separates the heading into a layout

I have an HTML div element that just isn't behaving right when I resize the screen. The title pretty much sums it up: <div class='serveMessage'><strong>Fun fact:</strong>&nbsp;over 1,259,468 American students fail ev ...

Using identical class names in different components was not possible as the CSS was not being contained within the styled component's scope

I am encountering a frustrating issue that seems to defy the essence of CSS in JS. The problem arises when I use styled-components and attempt to apply a classname that is already used higher up in the React component tree within a styled component. Surpri ...

The transparency of the navigation menu is perplexing to me. I am unclear as to the reasoning behind it. I desire a

I am currently using a pre-made WordPress theme. Recently, I incorporated particles.js as the background for my website. The issue I am facing now is that my navigation menu is blending into the same color as the background. I have tried defining a separat ...