How to make

后端 未结 12 1237
日久生厌
日久生厌 2020-12-12 15:37

I am creating a registration form for a website. I want each label and its corresponding input element to appear on the same line.

Here\'s my code:

12条回答
  •  春和景丽
    2020-12-12 16:32

    I've done this several different ways but the only way I've found that keeps the labels and corresponding text/input data on the same line and always wraps perfectly to the width of the parent is to use display:inline table.

    CSS

    .container {
      display: inline-table;
      padding-right: 14px;
      margin-top:5px;
      margin-bottom:5px;
    }
    .fieldName {
      display: table-cell;
      vertical-align: middle;
      padding-right: 4px;
    }
    .data {
      display: table-cell;
    }
    

    HTML

提交回复
热议问题