Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to stop elements moving around
    text
    copied!<p>I have a relativly straightforward setup in that I have a form with a label next to a text box. I also have an image that is hidden unless a validation check is failed. This is what it looks like before the validation check:</p> <p><img src="https://i.stack.imgur.com/YAVVk.png" alt="enter image description here"></p> <p>Here is what it looks like if the validation check is failed:</p> <p><img src="https://i.stack.imgur.com/Qsnhm.png" alt="enter image description here"></p> <p>As you can see in the first image the label and text box are nicely aligned. However, in the second one the text box appears to get pushed down by around 10px.</p> <p>This is where the problem lies. I have tried a whole host of fixes to sort this issue out but I just can get everything to stay where it is (and be in line).</p> <p>Here is the HTML code:</p> <pre><code>&lt;ol class="forms"&gt; &lt;li&gt; &lt;label for="Name"&gt;Name*&lt;/label&gt; &lt;input type="text" name="name" id="Name" /&gt; &lt;img src="/Graphics/Other/Name-Alert.png" class="validateImage" id="Name-Image-Validation"&gt; &lt;/li&gt; ... ... </code></pre> <p>Here is the corresponding CSS code:</p> <pre><code>form ol { list-style-type:none; } form { text-align:left; margin:0px; } label { float: left; width: 85px; margin-top:5px; text-align:left; display:block; background:none; } input { width: 250px; margin:0 0 16px 10px; border:1px #bbb solid; padding:5px; background:none; color:#FFF; } select { margin-bottom:20px; } .clear { clear:both; } .validateImage { display:none; } </code></pre> <p>Finally here is the small piece of javascript that I use to validate the form:</p> <pre><code>var x=document.forms["email_form"]["name"].value; if (x==null || x=="") { document.getElementById('Name-Image-Validation').style.display='inline'; return false; } else { document.getElementById('Name-Image-Validation').style.display='none'; } </code></pre> <p>Please can someone help me fix this issue?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload