Yet Another Divs vs Tables issue: Forms

后端 未结 5 888
我寻月下人不归
我寻月下人不归 2020-12-01 18:51

[Meta-note:] I was browsing the question page, getting really tired of \"DIVS vs Tables\" \"When to use tables vs DIVS\" \"Are Divs better than Tables\" \"Tables versus CSS\

5条回答
  •  悲哀的现实
    2020-12-01 19:21

    What I usually do is :



    and in a CSS :

    label,input { display: block; float: left; margin-bottom: 1ex; }
    input { width: 20em; }
    label { text-align: right; width: 15em; padding-right: 2em; }
    br { clear: left; }
    

    Of course, you'll have to define the width according to your actual data :-)

    • First, give label and input display: block, so that it can be assigned a size and be lined up.
    • They both get float: left because Explorer does things a bit differently
    • Format the label nicely
    • hack the br so that there's a clear: left somewhere, and I remember that putting it on the label didn't work on some browser.

    Plus, with the br you get a nice formatting even if the browser does not support CSS :-)

提交回复
热议问题