The alignment of inline-block elements is not being maintained on the same line

Here's a question I have about my embedded form. Why does the display property of inline-block make the "submit" and "terms" elements appear higher than the email field? And more importantly, how can I fix this issue?

I've attempted to use the traditional approach of adjusting the margin-top, but unfortunately, it hasn't been successful. Let me provide you with a snippet of the code that I have implemented.

 var coll = document.getElementsByClassName("open-terms");
        var i;

        for (i = 0; i < coll.length; i++) {
        coll[i].addEventListener("click", function() {
            this.classList.toggle("close-terms");
            var content = document.getElementById("terms-wrapper");
            if (content.style.maxHeight){
            content.style.maxHeight = null;
            } else {
            content.style.maxHeight = content.scrollHeight + "px";
            } 
        });
        }
        body {
        font-family: century-gothic, 'AppleGothic';
        }
        #mlist-email {background-color: white; border: white solid 1px; font-size: 12px; font-family: inherit; text-transform: capitalize; padding: 0 22.5px 0 22.5px; height: 45px; font-family: century-gothic, sans-serif; letter-spacing: 0; font-weight: 400; font-size: 14px;}
        #mlist-email:focus {outline: none;}
        #close-chimpy {float: right; margin-right: 5px; letter-spacing: 6px; color: black; text-transform: uppercase;}
        #close-chimpy:hover {color: rgb(181,57,102)}
        #button-wrapper {text-align: center; position: absolute; bottom: 30px; right: 30px;}
        .mlist-trigger {background-color: pink; padding: 20px; font-family: century-gothic, 'AppleGothic'; width: 250px; cursor: pointer; transition: 0.3s;}
        .mlist-trigger:hover {opacity: 0.7;}
        #chimpy-lightbox input[type="email"]::placeholder {color: black;}
        #chimpy-lightbox {font-family: century-gothic, 'AppleGothic'; z-index: 2008; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(255,255,255,0.7); display: none;} 
        @media only screen and (max-width: 374px) {
            #chimpy-lightbox input[type="submit"] {padding: 0 !important; width: 68% !important;}
            .mlist-submit-wrapper {width: 100%; margin-left: 0; padding-top: 15px;} #mlist-email-wrapper {width: 100%; margin-left: 0;}
        }
        .open-terms {cursor: pointer; width: 100%; border: none; color: black; text-align: left; outline: none; font-size: 15px;}
        .close-terms:hover:after, .open-terms:hover:after {color: red;}
        .open-terms:after {content: 'Terms'; color: black; text-transform: uppercase; font-weight: bold; margin-left: 5px;}
        .close-terms:after {content: "Hide"; text-transform: uppercase;}
        .content {padding: 0 18px; max-height: 0; overflow: hidden; transition: max-height 0.2s ease-out; background-color: #f1f1f1;}
<link rel="stylesheet" href="https://use.typekit.net/oov2wcw.css">
<form name="mlist-form-validate" method="post" id="mlist-form">
            <div id="mlist-form-wrapper" style="padding-top: 200px; text-align: center;">
                <div id="mc_embed_signup_scroll">
                    <h2 style="text-transform: uppercase; letter-spacing: 6px;">Join</h2>
                    <div class="mlist-email-wrapper" style="display: inline-block; vertical-align: top;">
                        <label id="email-error" style="font-size: 10px; color: #ff0000; text-align: left; float: left; padding-top: 0px; display: none;"></label><br>
                        <input oninvalid=""  type="email" value="" placeholder="email" name="EMAIL" class="required email" id="mlist-email" required><br>
                    </div>
                    <div style="position: absolute; left: -5000px;" aria-hidden="true"><input type="text" name="b_f206f10b38a504434c650c6bf_5ce815006b" tabindex="-1" value=""></div>
                    <div class="mlist-submit-wrapper" style="display: inline-block;  white-space: nowrap"><input type="submit" value="Submit" name="subscribe" id="mlist-submit" class="button" required><br><a href="javascript:void(0)" class="open-terms"><span></span></a></div>
                    <div class="content" id="terms-wrapper">
                        <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
                    </div>
                </div>
            </div>
        </form>

Answer №1

 var elem = document.getElementsByClassName("open-terms");
        var idx;

        for (idx = 0; idx < elem.length; idx++) {
        elem[idx].addEventListener("click", function() {
            this.classList.toggle("close-terms");
            var contentDiv = document.getElementById("terms-wrapper");
            if (contentDiv.style.maxHeight){
            contentDiv.style.maxHeight = null;
            } else {
            contentDiv.style.maxHeight = contentDiv.scrollHeight + "px";
            } 
        });
        }
        body {
        font-family: century-gothic, 'AppleGothic';
        }
        #mlist-email {background-color: white; border: white solid 1px; font-size: 12px; font-family: inherit; text-transform: capitalize; padding: 0 22.5px 0 22.5px; height: 45px; font-family: century-gothic, sans-serif; letter-spacing: 0; font-weight: 400; font-size: 14px;}
        #mlist-email:focus {outline: none;}
        #close-chimpy {float: right; margin-right: 5px; letter-spacing: 6px; color: black; text-transform: uppercase;}
        #close-chimpy:hover {color: rgb(181,57,102)}
        #button-wrapper {text-align: center; position: absolute; bottom: 30px; right: 30px;}
        .mlist-trigger {background-color: pink; padding: 20px; font-family: century-gothic, 'AppleGothic'; width: 250px; cursor: pointer; transition: 0.3s;}
        .mlist-trigger:hover {opacity: 0.7;}
        #chimpy-lightbox input[type="email"]::placeholder {color: black;}
        #chimpy-lightbox {font-family: century-gothic, 'AppleGothic'; z-index: 2499; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(255,255,255,0.7); display: none;} 
        @media only screen and (max-width: 374px) {
            #chimpy-lightbox input[type="submit"] {padding: 0 !important; width: 68% !important;}
            .mlist-submit-wrapper {width: 100%; margin-left: 0; padding-top: 15px;} #mlist-email-wrapper {width: 100%; margin-left: 0;}
        }
        .open-terms {cursor: pointer; width: 100%; border: none; color: black; text-align: left; outline: none; font-size: 15px;}
        .close-terms:hover:after, .open-terms:hover:after {color: red;}
        .open-terms:after {content: 'Terms'; color: black; text-transform: uppercase; font-weight: bold; margin-left: 5px;}
        .close-terms:after {content: "Hide"; text-transform: uppercase;}
        .inner-content {padding: 0 18px; max-height: 0; overflow: hidden; transition: max-height 0.2s ease-out; background-color: #f1f1f1;}
<link rel="stylesheet" href="https://use.typekit.net/oov2wcw.css">
<form name="mlist-form-validate" method="post" id="mlist-form">
            <div id="mlist-form-wrapper" style="padding-top: 200px; text-align: center;">
                <div id="mc_embed_signup_scroll">
                    <h2 style="text-transform: uppercase; letter-spacing: 6px;">Join</h2>
                    <div class="mlist-email-wrapper" style="display: inline-block;vertical-align: super;">
                        <label id="email-error" style="font-size: 10px; color: #ff0000; text-align: left; float: left; padding-top: 0px; display: none;"></label><br>
                        <input oninvalid=""  type="email" value="" placeholder="email" name="EMAIL" class="required email" id="mlist-email" required><br>
                    </div>
                    <div style="position: absolute; left: -5000px;" aria-hidden="true"><input type="text" name="b_f206f10b38a504434c650c6bf_5ce815006b" tabindex="-1" value=""></div>
                    <div class="mlist-submit-wrapper" style="display: inline-block;  white-space: nowrap;vertical-align: middle;"><input type="submit" value="Submit" name="subscribe" id="mlist-submit" class="button" required><br><a href="javascript:void(0)" class="open-terms"><span></span></a></div>
                    <div class="inner-content" id="terms-wrapper">
                        <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
                    </div>
                </div>
            </div>
        </form>

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

overlaying an image with a CSS box and then dynamically removing it using JavaScript

I am new to JavaScript, so please bear with me if this question seems quite simple. I am facing an issue with my current task. There is an image on a web page. My goal is to place a black box on top of the image (using CSS) to cover it up. Then, with th ...

I am experiencing difficulty with my grid as it refuses to center elements

Hello everyone, this is my first post here. If I missed any important information or didn't present things correctly, please feel free to let me know. I'm currently a developer in training and recently had to work on my first website project aft ...

Adjusting the display property using the CSS plus symbol operator

I am currently in the process of designing a dropdown menu using CSS. The focus is on utilizing the following code snippet: #submenu_div { display: none; } #li_id:hover + #submenu_div { display: block; } UPDATE: Here is the corrected HTML structure ...

Tips for building and implementing Angular URL Parameters for URLs in the form: "component/#/?id=..."

I am currently facing a situation where I have an application with an existing user base. I am looking to avoid disrupting their current links for a smoother transition. However, the previous links are in this format: (server)/viewer/#/?id=12. Please see t ...

dynamic webpage resizing using html and css

Looking for a way to make my SharePoint window automatically resize when the user changes their browser size. I'm using the web version of SharePoint at work and don't have access to Designer. <style type="text/css"> #dgwrap { HEIGHT: ...

What is the jQuery plugin that can search for elements and display them in real-time within a DIV?

Currently, I am in search of a jQuery plugin that can assist me with the following: Ability to have an input field for user search text Search through my elements and display only those that match the search string entered by the user. Essentially creati ...

Storing notes using HTML5 local storage

I recently developed a unique note-taking web application where users can create multiple notes and switch between them using tabs on the left side. My next step was to implement local storage for saving these notes, so I inserted the following code: $(d ...

None of the angular directives are functioning properly in this code. The function attached to the submit button is not executing as expected

I've experimented with various Angular directives in this code, but none seem to be functioning properly. I'm wondering if a library file is missing or if there's some issue within the code itself, potentially related to the jQuery file. The ...

When using Ruby and Rack on Heroku to serve a static site, the CSS styling may not be

Trying to deploy a static site consisting of HTML, CSS, font, and image files with Ruby Rack has been a bit challenging. While the HTML displays perfectly in Chrome when running it locally, the CSS assets do not seem to be loading or being applied to the H ...

How to toggle the visibility of a div with multiple checkboxes using the iCheck plugin for jQuery

I customized my checkboxes using the icheck plugin to work with both single and multiple checkboxes, including a "Check all" option. Here is an example of how it looks in HTML: HTML : <div>Using Check all function</div> <div id="action" c ...

Do we actually need all of these DIVs?

Do you ever find yourself creating a div purely to house another element? Take for example, when designing a menu. You may create a div with specific styling and then place an unordered list within it. Alternatively, you could apply all the styling direc ...

Connect ng-models with checkboxes in input field

I am facing an issue with binding ng-models using ng-repeat in an input checkbox tag. Let me share my code and elaborate further. app/main.html: <div ng-repeat="feature in features"> <input type="checkbox" ng-model="features[$index].name"> ...

The div in Bootstrap is not becoming scrollable despite using "overflow: auto"

I have a unique setup with two divs nested inside another div. The first div contains a table, while the second div holds buttons. I'm trying to make the table div scrollable by using overflow-auto, but it's not working as expected. I suspect tha ...

Saving data from Material UI forms in TypeScript

Is there an effective method for storing values entered into the text fields on this page? const AddUserPage = () => ( <div> <PermanentDrawerLeft></PermanentDrawerLeft> <div className='main-content'> < ...

Utilizing jQuery to apply a class to an element and modify the CSS parameters with custom values simultaneously

Unsure if this idea is feasible, but I'll attempt to explain my requirements. I am interested in accomplishing something like the following: A CSS class with variables X, Y, and Z left undefined: .r {border-radius:Xpx;-webkit-border-radius:Ypx;-moz ...

Webpack 4 Failing to Properly Render Select Tag

I am encountering an issue with a basic select element that is not displaying correctly due to Webpack. The screenshot below illustrates the final rendered page source, where the closing tag for the select element has been incorrectly positioned before the ...

Unveiling and Shifting Among Concealed HTML Forms

After going through numerous tickets with similar questions, I still can't seem to achieve what I want. So, I have no choice but to ask this question myself. I currently have an HTML page with 2 forms and 2 buttons. Both forms are initially hidden us ...

Echoing data from an input form is not possible with an associative array

I'm having trouble printing the associative array after inserting data from an input box. Currently, I can only display the latest data entered in the input box. What I really want is to continuously add data to the array and display it every time new ...

Challenges with parsing JSON using jQuery

I am attempting to retrieve data from a page that returns JSON in order to store it in an array. The current code is functional, but I am encountering difficulties when trying to pass the variable (which should contain the content) into the jQuery.parseJSO ...

Is it true that outerHeight(true) excludes margins?

As stated in the JQuery documentation, the outerHeight(true) function should return the complete height of an element, including padding, border, and margins. However, I encountered a scenario where this functionality seemed to be flawed. You can find a co ...