简体   繁体   English

水平对齐不同 td 中的输入

[英]Align inputs in different td horizontally

I am trying to align 2 inputs in 2 different td tag to align horizontally.我正在尝试对齐 2 个不同td标签中的 2 个输入以水平对齐。 Moreover, when input has been appended into td , it will cover the td text此外,当input被附加到td时,它将覆盖td文本

在此处输入图像描述

There are 2 cases:有2种情况:

  • When both of td have text or empty, then everything is OK.td都有文本或为空时,一切正常。
  • When one of the 2 td has text, they do not align on same line当 2 个td之一有文本时,它们不会在同一行对齐

This is my source code I have tried: https://jsfiddle.net/oc8Lgm3y/2/这是我尝试过的源代码: https://jsfiddle.net/oc8Lgm3y/2/

you can add vertical-align:bottom;您可以添加vertical-align:bottom; to the td,th .td,th

You can check the source code here: https://jsfiddle.net/k1gapfmq/你可以在这里查看源代码: https://jsfiddle.net/k1gapfmq/

table {
  font-family: arial, sans-serif;
  border-collapse: collapse;
  width: 50%;
}

td, th {
  border: 1px solid #dddddd;
  text-align: left;
  vertical-align: bottom;
  padding: 8px;
}

input[name=^='product'] {
  background-color: red;
}

html表格

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM