html form - make inputs appear on the same line

前端 未结 7 2134
臣服心动
臣服心动 2021-01-03 19:17

I am struggling to make two html form inputs (first and last name) appear on the same line side by side. I have tried using float, but that seems to make the rest of the inp

7条回答
  •  说谎
    说谎 (楼主)
    2021-01-03 20:03

    A more modern solution:

    Using display: flex and flex-direction: row

    form {
      display: flex; /* 2. display flex to the rescue */
      flex-direction: row;
    }
    
    label, input {
      display: block; /* 1. oh noes, my inputs are styled as block... */
    }

提交回复
热议问题