What is the best way to maintain the same height for a textarea and input fields?

What is the best way to align the message input field with the name and phone input fields?

I need the height of the message input field to match the combined height of the three inputs on the left. It's crucial that the borders line up perfectly.

I've attempted setting a fixed height for the message input field, but it becomes unpredictable when the window size changes, disrupting the design.

Is there a responsive solution to achieve this alignment?

https://i.sstatic.net/0eHuq.png

To replicate the desired results shown in the image, you may need to expand the viewable area (due to bootstrap md) Here is a link to an external example. https://jsfiddle.net/6ma7ndmL/3/

@import url('https://fonts.googleapis.com/css?family=Roboto+Mono:100,300,400,500,700');
 section {
  width: 100%;
  padding: 4em 0;
}
@media screen and (min-width: 768px) {
  section .container,
  section .row {
    padding: 0;
  }
}
header.section-header {
  text-align: center;
  padding: 0 0 3em;
}
header.section-header h2 {
  font-size: 2em;
}
section.contact form {
  font-family: 'Roboto Mono';
  color: #000;
}
section.contact form input,
section.contact form textarea {
  border-color: #000;
  border-width: 2px;
  border-radius: 0;
  transition: 0.4s border-color ease;
}
section.contact form input:focus,
section.contact form textarea:focus {
  transition: 0.4s border-color ease;
  border-color: #f33;
}
section.contact form textarea {
  resize: none;
}
section.contact form button.btn {
  background-color: #000;
  border-color: #000;
  border-width: 2px;
  color: #fff;
  outline: none;
  border-radius: 0;
  float: right;
  transition: 0.4s background-color ease, 0.4s color ease, 0.4s border-color ease;
}
section.contact form button.btn:hover {
  transition: 0.4s background-color ease, 0.4s color ease, 0.4s border-color ease;
  background-color: #fff;
  color: #000;
  border-color: #f33;
}
@media screen and (min-width: 768px) {
  section.contact form [class^='col-']:nth-child(1) {
    padding-left: 0;
  }
  section.contact form [class^='col-']:nth-child(2) {
    padding-right: 0;
  }
  section.contact form [class^='col-']:nth-child(3) {
    padding: 0;
  }
}
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.5/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.3.7/js/tether.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.5/css/bootstrap.min.css" rel="stylesheet" />
<div id="contact">
  <section class="contact">
    <div class="container">
      <div class="row">
        <header class="section-header">
          <h2>contact</h2>
        </header>
        <div class="col-lg-10 offset-lg-1">
          <form action="" method="post">
            <div class="col-md-6">
              <div class="form-group">
                <input id="name" type="text" name="name" class="form-control" />
                <label for="name">name</label>
              </div>
              <div class="form-group">
                <input id="email" type="email" name="email" class="form-control" />
                <label for="email">email</label>
              </div>
              <div class="form-group">
                <input id="phone" type="tel" name="phone" class="form-control" />
                <label for="phone">phone</label>
              </div>
            </div>
            <div class="col-md-6">
              <div class="form-group">
                <textarea id="message" name="message" class="form-control"></textarea>
                <label for="message">message</label>
              </div>
            </div>
            <div class="col-sm-12">
              <div class="form-group">
                <button id="formsubmit" type="submit" class="btn">send</button>
              </div>
            </div>
          </form>
        </div>
      </div>
    </div>
  </section>
</div>

Answer №1

After testing it out, this code is functioning perfectly. Check out the demo on Fiddle Update: If my understanding is correct, this is the code you are looking for.

section.contact form textarea {
    line-height: 98.5px !important;
}

Precisely 98.5 pixels :) Alternatively, you can achieve the same result with some JavaScript by using this snippet.

document.getElementById("message").rows = "10";

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

I am experiencing an issue with the interaction between my "label" tag and "summary" tag. The details are not opening when I click on the label. Can someone please provide guidance on how to resolve this

I have reviewed the question here, but it does not provide an answer, and there's also this related question. However, my question has a slightly different angle. I am encountering an issue where adding another element inside the summary tag prevents ...

What's the best way to integrate Bootstrap into my HTML document?

Hey there, I'm new to the coding world and just started learning. I could use some assistance with including Bootstrap v5.1 in my HTML code. The online course I'm taking is using an older version of Bootstrap, so I'm having trouble finding t ...

Is it possible to extract a div from a third-party domain and showcase it on my website?

Trying to integrate content from my Veetle.com channel onto my personal website has proven to be quite the challenge. Initially, I attempted to modify an iframe with CSS to display only the schedule information, but encountered limitations due to using 3rd ...

The waveform's bottom appears distorted when using Bootstrap

I'm currently experimenting with creating a header wave in Bootstrap CSS using SVG shape. However, I encountered an issue when implementing bootstrap into the HTML code - my design resembles the second image instead of the desired look of the first on ...

Frequently encountering broken styles in Magento 1.9 due to missing CSS and JS files

Recently, I've been facing frequent style breaking issues on my Magento sites (1.9.2+). This results in the home page displaying only text with missing CSS, JS, and images. To fix this problem, I usually clear the cache by deleting the var/cache fold ...

The input field does not accept any values even after setting it to be editable

Hey there! I have a specific requirement where I need to edit certain fields by clicking on an edit link. Initially, these fields will be disabled and in a readonly state. Once I click on the edit link, the field should become blank and editable. The issu ...

Spree Deluxe - Customizing color scheme variables

We're struggling to modify the color variables in Spree Fancy. The documentation suggests creating a variables_override.css.scss file. But where exactly should this file be placed? We've tried adding it under the stylesheets folder in assets and ...

Having trouble getting my Leaflet map to display even after meticulously following the quick-start guide

I am experiencing an issue where the map is not displaying at all, leaving a blank space where it should be. Despite following Leaflet's quick-start guide, I have been unable to determine the cause of this problem. Here is the code that I currently h ...

Changing color of navigation bar link upon refreshing the page using Bootstrap

I am new to the world of HTML/CSS/Bootstrap and recently made a change to the color of a link on the navbar. However, I am encountering an issue where the original blue color of the link briefly appears when I refresh the page. I would like to prevent this ...

Issues with the play() method in Javascript across Firefox, Safari, and IE 11 are causing functionality problems

I developed a basic video and audio player that smoothly fades out an introductory image and starts or stops playing an mp4 file upon click. Everything functions properly in Chrome, but unfortunately does not work in other major browsers. Despite checking ...

Jquery unresponsive in AJAX form output presentation

I recently delved into the world of jquery and AJAX, and while I grasp most concepts, I'm struggling with a small code snippet. On my webpage, there is a summary of articles. Clicking on an article name triggers a popup window with detailed informati ...

Tips for dynamically including classes in NextJS component with class names from CMS?

I am in search of a solution that will offer some styling flexibility within a CMS to dynamically alter the classes of specific components within my NextJS application. The code snippet I'm working with is as follows: pages/index.js: ... import clien ...

What is the best way to send data to PHP while moving objects between different div elements?

I have a situation where I have two parent divs containing dynamic children divs, and I want to enable POST requests to PHP when items are dragged from one side to the other (and vice versa). Here is the Javascript code I am using: function allowDrop( ...

Utilize JQuery variables for toggling the visibility of various DIV elements

On my webpage's splash page, there are 4 divs but only the home div is initially visible. The other three are hidden. Each of these divs has a button associated with it that triggers a jquery click event to swap out the currently visible div for the ...

Receiving an error of "undefined" when trying to capture the selected

One issue I am facing is capturing the selected user option and sending that value in a post request. Let's put aside the post part since it's not directly related to the main question at hand. Currently, the value is showing up as undefined. ...

Having EventListeners set up across a single CSS class returns null when applied to different types of elements simultaneously

I want to create floating labels that resize dynamically when an input is clicked, similar to modern forms. I am using vanilla JS exclusively for this task. Currently, the setup works with the <input> tag. However, it does not work with the <text ...

PHP code that prevents undefined index when uploading photos. Ensure photos are successfully inserted into an SQL

Currently, I am dealing with a registration form that includes an option for users to upload a photo for their profile picture. Everything works smoothly when trying to submit the form except for the errors related to the picture index. I strongly believe ...

Ensuring grid columns are equal for varying text sizes

I am looking to achieve equal width and spacing for columns without using the width, min-width, max-width properties. Can anyone help me accomplish this using flex or any other method? https://i.sstatic.net/xo56M.png .d-flex { display: flex; } .d-fl ...

JavaScript generating HTML code causing malfunctions

I have been attempting to implement the IN Place Editing feature using JQuery. Below is the code snippet editinplace.js $(document).ready(function() { //When div.edit me is clicked, run this function $("div.editme").click(function() { // ...

Trigger a function when clicking outside the element, similar to how a Bootstrap modal is closed

I have successfully created a popup box using angular in my project. It appears when I click on an icon and disappears when I click on the close button. However, I would like it to also close if someone clicks outside of the popup. Can anyone help me with ...