Input Fields Will Not Resize Correctly in Some Browsers

When resizing a browser, the input fields do not resize properly and end up overlapping each other in the middle, causing distortion before the media script adjusts everything to 100%. The width of the text area set to 100% does not align with the forms. Figuring out this contact form has been quite challenging, and I haven't even attempted to tackle getting it to send an email yet!

Click here to view the design.

Bonus query: Why must the input be wrapped in a span, or it completely disregards the parent divs' boundaries?

Per your request, you can find the JSFIDDLE script here.

.Block {
    width: 100%;
    background-color: #edeeef;
    padding: 50px 0;
    }

.Block:nth-of-type(odd) {
background-color: #ffffff;
}

.Block:After {
content: '';
display: block;
clear: both;
overflow: hidden;
Zoom: 1;
height: 0;
}

.BlockWrapper {
text-align: center;
Max-Width: 60%;
margin: 0 auto;
}

.BlockSizer1, .BlockSizer2, .BlockSizer3 {
float: left;
text-align: left;
}

.BlockSizer1 {
Width: 100%;
}

.BlockSizer2 {
width: 49%;
}

.BlockSizer3 {
width: 33%;
}
#ContactForm {
Padding: 5px;
}

#ContactForm span {
width: 49%;
padding: 5px 0 0 0; 
display: inline-block;
}

#ContactForm > .textarea {
width: 100%;
}

#ContactForm > .textarea textarea {
width: 98%;
Min-Height: 200px;
margin: 1em 0 1em 0em;
}

#ContactForm input {
width: 92%;
color: #999999;
outline: none;
padding: 10px;
Border: 1px solid #a0a0a0;
}

.ContactFormButton, .ContactFormButton input {
Width: 100% !important;
}

@Media screen and (max-width: 1000px) {
div.ContactForm, div.ContactFormRight {
width: 100%;
Margin: 5px 0;
float: none;
padding: 0;
}
}

textarea.ContactForm {
width: 100%;
padding: 10px;
Min-Height: 200px;
}

Answer №1

take a look at this code snippet to update your media query

<style>
    .Block {
        width: 100%;
        background-color: #edeeef;
        padding: 50px 0;
    }

    .Block:nth-of-type(odd) {
        background-color: #ffffff;
    }

    .Block:After {
        content: '';
        display: block;
        clear: both;
        overflow: hidden;
        Zoom: 1;
        height: 0;
    }

    .BlockWrapper {
        text-align: center;
        Max-Width: 60%;
        margin: 0 auto;
    }

    .BlockSizer1, .BlockSizer2, .BlockSizer3 {
        float: left;
        text-align: left;
    }

    .BlockSizer1 {
        Width: 100%;
    }

    .BlockSizer2 {
        width: 49%;
    }

    .BlockSizer3 {
        width: 33%;
    }

    #ContactForm {
        Padding: 5px;
    }

    #ContactForm span {
        width: 49%;
        padding: 5px 0 0 0;
        display: inline-block;
    }

    #ContactForm > .textarea {
        width: 100%;
    }

    #ContactForm > .textarea textarea {
        width: 98%;
        Min-Height: 200px;
        margin: 1em 0 1em 0em;
    }

    #ContactForm input {
        width: 98%;
        color: #999999;
        outline: none;
        padding: 10px;
        Border: 1px solid #a0a0a0;
    }

    .ContactFormButton, .ContactFormButton input {
        Width: 100% !important;
    }

    textarea.ContactForm {
        width: 100%;
        padding: 10px;
        Min-Height: 200px;
    }

    @media screen and (max-width: 1000px) {
        div.ContactForm, div.ContactFormRight {
            width: 100%;
            Margin: 5px 0;
            float: none;
            padding: 0;
        }

        .BlockWrapper {
            width: 100%;
        }

        .BlockSizer2 {
            width: 100%;
        }

        #ContactForm span {
            width: 100%;
            padding: 5px 0 0 0;
            display: inline-block;
        }

    }

</style>
<div class="Block">
    <div class="BlockWrapper">
        <div class="BlockSizer2">
            <form ID="ContactForm" action="#" method="post">
                <h1>Contact Me</h1>

                <p>Lorem ipsum primis in faucibus. Praesent faucibus massa elit, vitae ultrices libero dapibus nec.
                    Maecenas cursus rutrum odio ut convallis. Curabitur viverra est in diam tincidunt, nec tincidunt
                    tortor dapibus.</p>
                <span><input type="text" name="Name" placeholder="Name" required=""/></span>
                <span class="ContactFormRight"><input class="" type="text" name="Subject" placeholder="Company Name"
                                                      required=""/></span>
                <span><input type="email" name="Email" placeholder="Email" required=""/></span>
                <span class="ContactFormRight"><input type="text" name="Phone" placeholder="Phone" required=""/></span>
                <span class="textarea"><textarea name="Message" placeholder="Message..." required></textarea></span>
                <span class="ContactFormButton"><input type="submit" value="Submit"></span>
            </form>
        </div>
        <div class="BlockSizer2">

        </div>
    </div>
</div>

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

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

Answer №2

Here is a revised and cleaner edition, addressing the span problem :

.Block {
width : 350px;
margin : auto;
margin-top : 25px;
}

#contactform .flex {
display : flex;
justify-content : space-between;
margin-top : 15px;
}

#contactform .flex input {
width : 47%;
height : 35px;
padding : 5px;
}

#contactform textarea {
width : 100%;
height : 100px;
margin-top : 15px;
}

#contactform #submit {
display : block;
margin : auto;
margin-top : 15px;
width : 100%;
height : 35px;
cursor : pointer;
}
<div class="Block">

<h1>Contact Me</h1>
<p>Lorem ipsum primis in faucibus. Praesent faucibus massa elit, vitae ultrices libero dapibus nec. Maecenas cursus rutrum odio ut convallis. Curabitur viverra est in diam tincidunt, nec tincidunt tortor dapibus.</p>

<form id="contactform" action="#" method="post">

<div class="flex">
<input type="text" name="Name" placeholder="Name" required />
<input type="text" name="CompanyName" placeholder="Company Name" />
</div>
<div class="flex">
<input type="text" name="Email" placeholder="Email" />
<input type="text" name="Phone" placeholder="Phone" />
</div>

<textarea name="Message" placeholder="Message..."></textarea>

<input id="submit" type="submit" value="Submit"/>

</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

Tips for preloading a small placeholder image before the main content is loaded

After browsing , I noticed an interesting image loading style. The website initially shows a patterned image before revealing the actual content. This method creates visually appealing content while waiting for the entire webpage to load. Upon inspecting ...

Changing the alignment of divs to center instead of the right side

I am currently working on a project that involves creating a tiled interface with responsive tiles. One issue I have encountered is that all the tiles are shifting to the left side of the div and not getting centered, no matter what I try. To see the pro ...

pre-iframe loading function

Is it possible to capture the state of an iframe while data is loading? The onload event only fires once all content has finished loading. I would appreciate any assistance with this issue. Thank you. ...

Ways to have the "li" element displayed on a separate line

let selector = document.querySelector('.activate') selector.addEventListener('mouseover', function(){ document.querySelector('#hidden-li').classList.remove("hidden") }) selector.addEventListener('mouseleave', f ...

Interactive element for initiating a HTTP request to NodeJS/Express server to trigger a specific function

I currently have a frontend button implemented using nodejs and express for my server-side backend. The button is supposed to trigger a function that controls the Philips Hue API on the backend via an HTTP request. I have experimented with various approac ...

Is there a way to turn off the ripple effect on Material UI Input components?

Is there a way to turn off the ripple effect or highlight color on the TextField component in React's Material UI? https://i.sstatic.net/qB2cm.png I've attempted to modify the theme: theme.props.MuiTab.disableRipple = true theme.props.MuiButto ...

Enhancing images by creating clickable sections in a more organized and efficient manner

Are there any other methods to make parts of an image clickable in a more organized way, aside from using the coordinates method or directly embedding images from Photoshop? <script> new el_teacher = ["candice","john"]; $(".teacher1").mouseenter(fu ...

Steps for creating a fade effect between two different elements when the mouse is interacting with one of them

I want to create a unique effect with an image in the background and a button above it. When the mouse hovers over the button, I want its opacity to decrease while the image's opacity increases simultaneously. I have experience applying fade effects ...

Styling errors in AngularJS validation code

I am facing an issue with the code below that generates 3 text boxes. When I click on one text box, all 3 of them get focused, despite having different name and label values. <div class="col-md-12" data-ng-repeat="dohPolicy in [1,2,3]"> <div ...

Eliminating the bottom border of all buttons, except for the last three buttons in the list, solely using pure JavaScript, unless alternative methods are available

I have 3 sets of buttons, with each set containing 9 buttons stacked in 3 columns inside an ordered list (ol) within list items (li). I have removed the bottom border of the buttons to avoid double borders since they are stacked on top of each other withou ...

Prevent the rendering of HTML in the combobox dropdown menu

Utilizing ExtJs 3.1 In my Ext.form.ComboBox, the store includes values such as: "value1", "<value2>", "value3". The issue arises when the combobox dropdown list is displayed, and "<value2>" is being interpreted as an HTML tag. This is causing ...

In JavaScript, alert a message once all images have been clicked

I'm encountering a small issue with my javascript code. I am developing a game for a school project where the objective is to click (remove) fish using a fishing rod. However, the game does not have an end condition set up, so players cannot win. Belo ...

Inquiries regarding the formatting of HTML tables

image description hereI'm facing an issue with displaying a table in HTML. I've been struggling for three days to find a solution, asked multiple questions without success. Any help would be greatly appreciated. I am trying to use the table tag a ...

Rotating an input 90 degrees within a div for unique positioning

I used JavaScript to make an input range vertical, like so: var range_pitch = document.createElement("input"); range_pitch.setAttribute("type", "range"); range_pitch.style.webkitTransform = "rotate(90deg)"; range_pitch.style.mozTransform = "rotate(90deg)" ...

Ways to contrast HTML without considering whitespace?

I'm currently testing an HTML builder through unit testing. My goal is to confirm that the output content matches the expected content, while allowing for some leniency when it comes to white space. More specifically, I am not concerned with whether ...

Ways to showcase JSON data with jQuery

My code displays movie data from a JSON variable and populates it on a dropdown list based on the selected city. I aim to include show timings along with other details from the JSON content. The code snippet is as follows: $(document).ready(function() ...

Using a for loop in JavaScript to dynamically generate HTML content within a Django project

Do you have a unique question to ask? Version: Django version 3.0.8 This block contains my JavaScript code: fetch(`/loadbox/${message.id}`) .then(response => response.json()) .then(dialog => { let detailcontent= `<div class=" ...

Issue: The value of an object is not defined (evaluating '$scope.inputcode.password')

HTML Form: <form ng-submit="mylogin()"> <div class="list"> <label class="item item-input"> <span class="input-label">Username</span> <input type="text" ng-model="inputcode.username"> ...

Is it possible to reset the text within the text box when the form is being submitted using the load() ajax function?

I am working on implementing a comment feature where the data entered in the form is appended and displayed after submission. Here is my HTML form: <table> <tr><td>Name :</td><td> <input type="text" id="name"/></td&g ...

Exploring the benefits of utilizing Scoped CSS for individual components within Next.js version 13

Switching from a Vue.js background to starting with Next.js, I want to scope my CSS for each component such as Navbar instead of using it inside Globas.css. Is there a way to achieve this? I am also utilizing the Tailwind CSS library. I attempted creatin ...