question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Modal]: Input fields and label incorrectly aligned

See original GitHub issue

When using input fields inside a modal they aren’t aligned properly:

<a class="waves-effect waves-light btn" data-login>Login</a>

    <div id="modal1" class="modal">
        <div class="modal-content">
            <h4>Login</h4>

            <div class="row">
                <div>
                    <input value="Alvin" id="first_name2" type="text">
                    <label class="active" for="first_name2">Username:</label>
                </div>
            </div>

        </div>
        <div class="modal-footer">
            <a href="#!" class=" modal-action modal-close waves-effect waves-green btn-flat">Agree</a>
        </div>
    </div>


I am using meteor, and the button click event is registered in the following way:

'click [data-login]': (event: Event, template: Template) => {
    $('#modal1').openModal();

}

screen shot 2015-06-25 at 16 28 17

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
Aranircommented, Jun 25, 2015

I tested it in different conditions at it appears it has to do with meteors template rendering in combination with the nav bar.

If I have the button (to display the navbar) inside a navbar and the modal from a different template, the alignment seems to be incorrect:

//layout.html

<template name="layout">

    <nav>
        <div class="nav-wrapper">
            <a href="#" class="brand-logo">Pay Me Back</a>
            <ul id="nav-mobile" class="right hide-on-med-and-down">
                <li>
                    <div class="row col s4">
                        {{> loginTemplate}}

                    </div>
                </li>
            </ul>
        </div>
    </nav>
    </div>
</template>

//loginTemplate.html

<template name="loginTemplate">
    <!-- Modal Button -->
        <a class="waves-effect waves-light btn" data-login>Login</a>

    <!-- Modal Structure -->
    <div id="modal1" class="modal">
        <div class="modal-content">
            <h4>Login</h4>

            <div class="row">
                <form class="col s12">
                    <div class="row">
                        <div class="input-field col s6">
                            <input placeholder="Placeholder" id="first_name" type="text" class="validate">
                            <label class="active" for="first_name">First Name</label>
                        </div>
                        <div class="input-field col s6">
                            <input id="last_name" type="text" class="validate">
                            <label for="last_name">Last Name</label>
                        </div>
                    </div>
                </form>
            </div>

        </div>
        <div class="modal-footer">
            <a href="#!" class=" modal-action modal-close waves-effect waves-green btn-flat">Agree</a>
        </div>
    </div>
</template>

If instead the modal definition is inside the layout.html it works correctly.

Therefore I assume it has something to do with rendering templates and the navbar, as if I use the same template (including the modal definition) outside the navbar it displays everything in the correct way.

0reactions
fegacommented, Jul 28, 2017

@Zerebokep please provide a codepen illustrating the problem

Read more comments on GitHub >

github_iconTop Results From Across the Web

Elements within a bootstrap modal form are not lining up
I was expecting the "radio" buttons and the date input text field will align, but they don't. Help, can someone point to things...
Read more >
How to Align Lightning Component Label and Fields
It's never hard to make the input field and the label appear in 1 line where the input box has similar alignment with...
Read more >
Common problems - The jQuery replacement for select boxes
Select2 does not function properly when I use it inside a Bootstrap modal. This issue occurs because Bootstrap modals tend to steal focus...
Read more >
How to pass data into a bootstrap modal? - GeeksforGeeks
Example 1: In this approach, the web page consists of two input fields Name and Marks which accepts input from the user. The...
Read more >
Box alignment in Flexbox - CSS: Cascading Style Sheets | MDN
The first item overrides the align-items values set on the group by setting align-self to center . One. Two. Three has extra text...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found