html - 如何让 td 占据 tr 的 50%

标签 html css html-table

我有以下片段。它有一个问题 - Enter your passcode: td 占用太多空间,而且看起来很丑。

我尝试将 width:50% 设置为那个,但没有成功。

我想要实现的是输入字段与 Expertise Organization 按钮对齐。

我该怎么做?

提前致谢。

.prettyEGRZButton {
  width: 100%; 
  padding: 20px; 
  text-align: center; 
  text-decoration: none;
  display: inline-block;
  font-size: 16px;
  margin: 4px 2px; 
  cursor:	pointer;
  border-radius: 12px; 
  border: 1px solid #05788d;
   	  color: #05788d;
  background: transparent;
}

.prettyEGRZButtonActive {
 color: white;
 background: #05788d;
}
<div id="view:_id1:egrzFinishAuthPopUp" class="egrzFinishAuthPopUp">
  <div id="view:_id1:organizationsRepeat">
  </div>
  <div id="view:_id1:rolesRepeat">
  </div>
  <table id="view:_id1:egrzFinishAuthPopUpTable" role="presentation">
    <tbody>
      <tr align="center">
        <td>
          <span class="xspTextLabel">To proceed, please authorize</span>
        </td>
      </tr>
      <tr align="center">
        <td>
          <span class="xspTextLabel">Authorize as natural person</span>
        </td>
      </tr>
      <tr id="view:_id1:authAsPersonTr">
        <td id="view:_id1:authAsPersonTd">
          <button class="prettyEGRZButton" type="button" name="view:_id1:authAsPersonButton" id="view:_id1:authAsPersonButton">John Doe</button>
        </td>
      </tr>
      <tr align="center">
        <td>
          <span class="xspTextLabel">Authorize as organization</span>
        </td>
      </tr>
      <tr id="view:_id1:organizationsRepeat:0:authAsOrgTr">
        <td id="view:_id1:organizationsRepeat:0:authAsOrgTd">
          <button class="prettyEGRZButton" type="button" name="view:_id1:organizationsRepeat:0:authAsOrgButton" id="view:_id1:organizationsRepeat:0:authAsOrgButton">Company 1</button>
        </td>
      </tr>
      <tr id="view:_id1:organizationsRepeat:1:authAsOrgTr">
        <td id="view:_id1:organizationsRepeat:1:authAsOrgTd">
          <button class="prettyEGRZButton prettyEGRZButtonActive" type="button" name="view:_id1:organizationsRepeat:1:authAsOrgButton" id="view:_id1:organizationsRepeat:1:authAsOrgButton">Company 2</button>
        </td>
      </tr>
      <tr id="view:_id1:rolesRepeat:0:roleTr">
        <td id="view:_id1:rolesRepeat:0:roleTd">
          <button class="prettyEGRZButton" type="button" name="view:_id1:rolesRepeat:0:roleButton" id="view:_id1:rolesRepeat:0:roleButton">Government Organization</button>
        </td>
      </tr>
      <tr id="view:_id1:rolesRepeat:1:roleTr">
        <td id="view:_id1:rolesRepeat:1:roleTd">
          <button class="prettyEGRZButton" type="button" name="view:_id1:rolesRepeat:1:roleButton" id="view:_id1:rolesRepeat:1:roleButton">Expertise Organization</button>
        </td>
      </tr>
      <tr>
        <td>
          <span class="xspTextComputedField">Enter your passcode:</span>
        </td>
        <td>
          <input id="view:_id1:inputText1" type="password" name="view:_id1:inputText1" value="" class="xspInputFieldSecret">
        </td>
      </tr>
    </tbody>
  </table>
</div>

最佳答案

您的第一对 tr 只有一个 td。所以底层 tr 需要兑现它。您可以使用两行使其对齐。

.prettyEGRZButton
	{
		width: 100%; 
		padding: 20px; 
		text-align: center; 
		text-decoration: none;
		display: inline-block;
		font-size: 16px;
		margin: 4px 2px; 
		cursor:	pointer;
		border-radius: 12px; 
		border: 1px solid #05788d;
		
		color: #05788d;
		background: transparent; 
	}
	
	.prettyEGRZButtonActive
	{ 
		color: white;
		background: #05788d;
	}

.xspInputFieldSecret{
width:100%;
}
<div id="view:_id1:egrzFinishAuthPopUp" class="egrzFinishAuthPopUp"><div id="view:_id1:organizationsRepeat">
</div><div id="view:_id1:rolesRepeat">
</div><table id="view:_id1:egrzFinishAuthPopUpTable" role="presentation"><tbody><tr align="center"><td><span class="xspTextLabel">To proceed, please authorize</span></td>
</tr>
<tr align="center"><td><span class="xspTextLabel">Authorize as natural person</span></td>
</tr>
<tr id="view:_id1:authAsPersonTr"><td id="view:_id1:authAsPersonTd"><button class="prettyEGRZButton" type="button" name="view:_id1:authAsPersonButton" id="view:_id1:authAsPersonButton">John Doe</button></td>
</tr>
<tr align="center"><td><span class="xspTextLabel">Authorize as organization</span></td>
</tr>
<tr id="view:_id1:organizationsRepeat:0:authAsOrgTr"><td id="view:_id1:organizationsRepeat:0:authAsOrgTd"><button class="prettyEGRZButton" type="button" name="view:_id1:organizationsRepeat:0:authAsOrgButton" id="view:_id1:organizationsRepeat:0:authAsOrgButton">Company 1</button></td>
</tr>
<tr id="view:_id1:organizationsRepeat:1:authAsOrgTr"><td id="view:_id1:organizationsRepeat:1:authAsOrgTd"><button class="prettyEGRZButton prettyEGRZButtonActive" type="button" name="view:_id1:organizationsRepeat:1:authAsOrgButton" id="view:_id1:organizationsRepeat:1:authAsOrgButton">Company 2</button></td>
</tr>

<tr id="view:_id1:rolesRepeat:0:roleTr"><td id="view:_id1:rolesRepeat:0:roleTd"><button class="prettyEGRZButton" type="button" name="view:_id1:rolesRepeat:0:roleButton" id="view:_id1:rolesRepeat:0:roleButton">Government Organization</button></td>
</tr>
<tr id="view:_id1:rolesRepeat:1:roleTr"><td id="view:_id1:rolesRepeat:1:roleTd"><button class="prettyEGRZButton" type="button" name="view:_id1:rolesRepeat:1:roleButton" id="view:_id1:rolesRepeat:1:roleButton">Expertise Organization</button></td>
</tr>


<tr><td><span class="xspTextComputedField">Enter your passcode:</span></td>
</tr><tr>
<td><input id="view:_id1:inputText1" type="password" name="view:_id1:inputText1" value="" class="xspInputFieldSecret"></td>
</tr>
</tbody></table>
</div>

关于html - 如何让 td 占据 tr 的 50%,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58863993/

相关文章:

JavaScript 迭代单元格子元素

html - 为什么左右浮动不堆叠在一起?它们之间的空间从何而来?

html - 我的 Django 元素没有显示正文背景

css - 如何保持iframe的纵横比

html - 如何将复选框移动到表格单元格的中心

php - 无法显示数据库中的表

html - 如何在一个div中居中一个div? ( margin : 0 auto; not working)

javascript - "zoom"/"scale"如何用css 或jquery 在div 的内容?

javascript - 加载元素后设置 onload 属性是否仍会运行处理程序?

javascript - 使用 jQuery 匹配表格单元格中的日期模式