CSS label text right below input element

后端 未结 4 1963
一个人的身影
一个人的身影 2021-02-05 10:08

I have input text\'s and label tags. I can\'t figure out the CSS to get the label text to align right below the input text. Here\'s a snippet of the HT

4条回答
  •  孤城傲影
    2021-02-05 10:44

    You can use pure css to get this to achieve what you want, but it requires a lot of adhoc positioning stuff that you're better off not doing.

    The simplest way is to put the label beneath the input on the html:

    Then you can wrap each input/label pair with a div, and set the div like so:

    #sg1 div { clear: both; float: left; }

    Next you can put

    #sg1 label
    {
        float: right;
    }
    
    input
    {
        display:block;
    }
    

提交回复
热议问题