Interactive HTML5 forms with movable fields on mouse click

I'm dealing with a specific issue in IE11 that's been really frustrating. Take a look at the form image below:

Everything works fine except for when users interact with form fields in the right column on IE11. It causes input fields in the left column to shift downwards:

Furthermore, if someone enters information in a field on the left side and then clicks or tabs into the right column, everything displays correctly:

Below is the HTML code snippet:

<div class="container-border">
  <h2>Billing Address:</h2>
  <input id="search" name="search" placeholder="Start typing a postcode or address" type="text" value />
  <div class="left container-half">  
    <input id="firstname" name="firstname" placeholder="First name(s)" type="text" value />
  </div>
  <div class="right container-half">
    <input id="lastname" name="lastname" placeholder="Last name" type="text" value />
  </div>
  <div class="left container-half">
    <input id="address1" name="address1" placeholder="Address 1" type="text" value />
  </div>
  <div class="right container-half">
    <input id="address2" name="address2" placeholder="Address 2" type="text" value />
  </div>
  <div class="left container-half">
    <input id="city" name="town" placeholder="City" type="text" value />
  </div>
  <div class="right container-half">
    <input id="postcode" name="postcode" placeholder="Postcode" type="text" value />
  </div>
  <div class="left container-half">
    <select class="country" id="country" name="country">
      <option value="">Country</option>
      <option selected="selected" value="GB">United Kingdom</option>
    </select>
  </div>
</div>

Here's the CSS code:

.left {
  float: left;
}

.right {
  float: right;
}

.container {
  margin-left: auto;
  margin-right: auto;
  width: 100%;
  max-width: 520px;
}

@media screen and (max-width: 520px) {
  .container {
    margin-left: 0;
    margin-right: 0;
  }
}

.container-half {
  width: 50%;
}

.container-half input[type="text"] {
  width: 90%;
  overflow: hidden;
}

.container-half select {
  width: 90%;
  overflow: hidden;
}

@media screen and (max-width: 520px) {
  .container-half {
    width: 100%;
    float: left;
  }

  .container-half input[type="text"],
  .container-half select {
    width: 100%;
    float: left;
  }
}

input[type="text"] {
  float: inherit;
  background-color : rgb(76, 171, 148); 
  box-shadow: none;
  border: none;
  width: 100%;
  padding: 12px;
  margin-top: 3px;
  margin-bottom: 3px;
  color: white;
}

select {
    padding: 12px;
    float: inherit;
    margin-top: 3px;
    margin-bottom: 3px;
    background-color: rgb(76,171,148);
    color: white;
    display: inline-block;
    border:none;
    width: 45%;
    box-shadow: none;
    -ms-box-sizing:content-box;
    -moz-box-sizing:content-box;
    -webkit-box-sizing:content-box; 
    box-sizing:content-box;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    cursor:pointer;
}

Any thoughts on what might be causing this strange behavior in IE11? The layout looks perfect in FF and Chrome.

Thank you,

Mike

Answer №1

Upon reviewing your second screenshot (the one labeled "moved"), it appears that the "Address 1" field is slightly smaller than the other fields. This issue may be due to Internet Explorer having trouble with width in percentage and margin in pixels. Since all elements are floated, my recommendation would be to add a clear after every double line and include an empty field element for extra space in case needed:

CSS:
.clearence
    {
        clear: both;
    }

HTML:
<div class = "container-border">
    <h2>Billing Address:</h2>
    <input id = "search" name = "search" placeholder = "Start typing a postcode or address" type = "text" value />
    <div class = "left container-half">
        <input id = "firstname" name = "firstname" placeholder = "First name(s)" type = "text" value />
    </div>
    <div class = "right container-half">
        <input id = "lastname" name = "lastname" placeholder = "Last name" type = "text" value />
    </div>
    <div class = "clearence"></div>
    <div class = "left container-half">
        <input id = "address1" name = "address1" placeholder = "Address 1" type = "text" value />
    </div>
    <div class = "right container-half">
        <input id = "address2" name = "address2" placeholder = "Address 2" type = "text" value />
    </div>
    <div class = "clearence"></div>
    <div class = "left container-half">
        <input id = "city" name = "town" placeholder = "City" type = "text" value />
    </div>
    <div class = "right container-half">
        <input id = "postcode" name = "postcode" placeholder = "Postcode" type = "text" value />
    </div>
    <div class = "clearence"></div>
    <div class = "left container-half">
        <select class = "country" id = "country" name = "country">
            <option value = "">Country</option>
            <option selected = "selected" value = "GB">United Kingdom</option>
        </select>
    </div>
    <div class = "right container-half">&nbsp;</div>
    <div class = "clearence"></div>
</div>

In addition, I believe you can remove the "value" attribute from the text fields if no default values are intended.

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

Problem with Swiper js arrow controls

I'm currently incorporating Swiper Js into my project and I'm facing an issue with styling the arrow buttons in the slider. Whenever I try to add classes to them, they stop functioning and disappear from the HTML. Here is the code snippet: < ...

Simple Timer App with Vanilla JavaScript

Hey there! I am a newcomer to JavaScript and recently joined the stackoverflow community. Currently, I am working on a project called Pomodoro Timer with the goal of creating something similar to this example: http://codepen.io/GeoffStorbeck/full/RPbGxZ/ ...

Tips for transferring the asp:Label ID from an asp:CheckBox

I have searched various online forums without success in finding a solution to my issue. I am looking for a way to retrieve an asp:Label's id and pass it to a JavaScript function using the "onclick" event from a nested asp:CheckBox. My goal is to pas ...

Match the test choices with the corresponding `radio` buttons

Looking for help with my quiz application. How can I align text vertically with radio buttons? Take a look at the code here on Codepen. One issue I'm facing is the alignment of long label texts, particularly in questions 9, 12 & 14. I've tried va ...

Load Jquery hover images before the users' interactions

Currently, I am in the process of creating a map of the United States. When hovering over any specific state, my goal is to replace the image with one of a different color. The issue I am encountering lies in the fact that the image gets replaced and a ne ...

Creating a Drop-Down Button Using HTML, CSS, and JavaScript

I am currently working with the following code: <link rel="preconnect" href="https://fonts.googleapis.com"> <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> <link href="https://fonts.googleapis.com/css2?family=PT+Sans ...

What is the best way to set up a website subdirectory and connect a button to it?

A group of friends and I recently created a real-life version of Among Us, but we think it could be even better if we had a website to go along with it. After doing some research and learning about HTML, CSS, JavaScript code, as well as websockets, I manag ...

Most effective method for adjusting image size to match div container (as background)

I'm attempting to create a background with 85% height and 100% width on the index page using Bootstrap 4. However, when I set an image as the background in a div, it doesn't resize correctly and only shows a portion of the image (as the image is ...

"Struggling with getting the text color to change on hover in Tailwind

Today has been a frustrating day as I am diving into the world of tailwindcss and have been struggling with a particular issue. My code is below: <button className="bg-yellow-500 px-4 py-2 hover:text-black text-white"> Some Text Her ...

What could be causing the issue with passing an ID through the href attribute of an anchor tag in

Greetings! I am working with a specific directory structure for my HTML files and have made adjustments to the .htaccess file to read .html files as .php when necessary. Snapshot 1: Directory structure https://i.sstatic.net/pHh67.png Snapshot 2: localho ...

Modifying the default text within a select box using jQuery

Within a select box identified as 'edit-field-service-line-tid', there is default text displayed as '-Any-'. This particular select field has been generated by Drupal. I am looking to use jQuery to change the text '-Any-' to ...

The hyperlink function is malfunctioning in HTML pages

Hello there, I'm having trouble linking HTML pages together. Here is the code snippet I am currently using: <nav class="navbar navbar-inverse"> <div class="container-fluid"> <div class="navbar-header"> <a class="navba ...

Can curly braces be utilized in the style section of Vue.js?

Can I utilize curly braces in the style section of vue.js to set a value? For instance .container { background: url({{ image-url }}; color: {{ color-1 }} } ...

How to change the tabIndex of an input element dynamically

In the Angular application I have developed, there is a form where users can input multiple sets of field values by clicking an add button. <md-content layout-padding=""> <div> <form name="userForm"> <div layout="row ...

Table formatting problem

I am looking to add borders only below each row in my table. td{ border-bottom-style: solid;} However, I am noticing a visible border break between columns. Can anyone advise on how to remove that? ...

Adding a scrollable feature to a Bootstrap Modal seems to be generating additional unnecessary pages at the

I need help with my scrollable bootstrap modal that has a print button on top. When the user clicks the button, I want to print the modal content. Here is the code snippet: HTML : <div class="container-fluid" id="body-noPrint"> /* HTML BODY CON ...

Visual Composer in WordPress is not displaying as expected

I've attempted to uninstall and reinstall Visual Composer, but I'm unable to resolve the issue. I can't edit the front end because it's not displaying properly. I'm using the Ken theme. When checking the console, I encountered this ...

Scrollbar not displaying on IE when set to overflow: auto

Greetings, all! I am facing yet another design challenge with Internet Explorer. I have a DIV with Overflow:auto on my website that works perfectly fine on Chrome. However, when it comes to IE, the scroll bar doesn't show up and all the images inside ...

React snap scrolling feature is not working as intended

I've been attempting to implement the snap scroll feature in my react app, but I'm facing issues with it. The regular CSS method doesn't seem to work well in Chrome, as discussed in this Scroll Snap Skips Section on Smaller Screen - Chrome t ...

Looking to authenticate a CSS span class within an XML document using Oxygen Program?

This is in connection with my initial query. The XML does not recognize the CSS span class. <l rend="indent"> <span class="face_dropcap_ ">C</span><hi rend="initial_roman">E</hi>stoit alors que le prefent des <span class= ...