Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why hidden input is affecting my layout? LF Explanation

Tags:

html

css

php

input

I needed to use an hidden input to transfer some IDs to the page for each block.. whatever.

I have the following code :

<div id="shipping_box" class="formSep well">
    <div id="default_shipping_box" class="shipping_box row-fluid">
        <div class="span1">
            <input type="hidden" name="tracking_id" value="" />
        </div>
    </div>
</div>

This code work well and the result is what I expected.

If I do this :

<div id="shipping_box" class="formSep well">
    <div id="default_shipping_box" class="shipping_box row-fluid">
        <input type="hidden" name="tracking_id" value="" />
        <div class="span1">

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

The layout is not respected. See this picture for the demostration :

enter image description here

Can someone explain why to me ? Hidden input aren't suppose to be "hidden" so they shouldn't affect the layout ?

jsfiddle : http://jsfiddle.net/t9M3C/

Near line 285

like image 769
David Bélanger Avatar asked Aug 15 '12 18:08

David Bélanger


People also ask

What happen when we define input type hidden?

The <input type="hidden"> defines a hidden input field. A hidden field lets web developers include data that cannot be seen or modified by users when a form is submitted. A hidden field often stores what database record that needs to be updated when the form is submitted.

Is input type hidden safe?

Since they are not rendered visible, hidden inputs are sometimes erroneously perceived as safe. But similar to session cookies, hidden form inputs store the software's state information client-side, instead of server-side. This makes it vulnerable.

What is the use of hidden in HTML?

The hidden attribute is used to indicate that the content of an element should not be presented to the user.


1 Answers

Is because you have a css rule (in bootstrap.min.css file) that match the firs-child element (but only if has a class*="span") inside the default_shipping_box div.

.row-fluid [class*="span"]:first-child {
margin-left: 0;
}

So, if you put your hidden input inside the div#default_shipping_box and before the first span, then that rule is not styling the div.span1 and thats why your template is been afected.

You can fixed adding a simple css rule to the same file...

.row-fluid .span1{margin-left:0 !important;}

The important, is because you have more files who overite this rule (ex. in bootstrap-responsive.min.css)

Good luck, and i hope it helps cheers, Gmo.-

EDIT: Too slow XD. Answered while writing ... I agree with the reason explained above.

like image 130
gmo Avatar answered Sep 21 '22 08:09

gmo