Aligning grid based form elements and their labels

前端 未结 2 1593
萌比男神i
萌比男神i 2021-01-23 23:02

we have a requirement where form elements are laid out in 3 separate columns. The labels can have varying amounts of text and the form elements will be mainly input boxes and te

相关标签:
2条回答
  • 2021-01-23 23:46

    Here is the fiddle: http://jsfiddle.net/nJZ6Y/19/

    You have to add a span inside each label, then add these CSS rules.

    label {
        min-height: 3em;
    }
    
    label span {
        vertical-align: -3em;
        display: inline-block;
    }
    
    0 讨论(0)
  • 2021-01-23 23:56

    Fiddle: http://jsfiddle.net/nJZ6Y/18/

    I added a box around the label element and aligned it to the bottom. This only works if you know the approximate max-height of the text though. If the text goes longer than that it will fall out of the container and go incognito. Fred's answer is more elegant. FYI: Bonorum in your lorem ipsum is a funny word...

        .label-box {
            position: relative;
        }
        .label-box {
            height: 50px;
        }
        label { 
            float:left; 
            width:100%; 
            color:#fff; 
            position: absolute; 
            bottom: 0; 
            left: 0;}
    
    0 讨论(0)
提交回复
热议问题