html - 如何在表 td 中将两个 div 并排放置
问题描述
下面是我的 html & css 代码。我需要将div
s 放在表格的单元格td
中。div "infoY" 应该显示在 "outerY" div 之后。
<td>
<div class="outerY"> <div class="yellow"></div> <div class="yellow"></div> <div class="yellow"></div> <div class="yellow" style="margin-right: 3px;"></div> </div><div class="infoY"></div></td>
解决方案
用于 display:flex
通缉td
编辑!我从评论中添加了 OP 的 css 代码
.infoY{
border: 3px solid #ffc107;
height: 20px;
background: #ffc107;
}
.outerY {
border: 3px solid #ffc107;
width: 74px;
height: 31px;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
padding: 2px;
border-radius: 8px;
position: relative;
}
.yellow {
background-color: #ffc107;
height: 100%;
-webkit-box-flex: 1;
flex: 1;
border-radius: 1px;
margin-left: 4px;
}
td, th {
border: 1px solid #dddddd;
}
.flex{
display:flex
}
<table>
<tr>
<th>x</th>
<th>y</th>
</tr>
<tr>
<td class="flex">
<div class="outerY">outerY
<div class="yellow"></div>
<div class="yellow"></div>
<div class="yellow"></div>
<div class="yellow" style="margin-right: 3px;"></div>
</div>
<div class="infoY">infoY</div>
</td>
<td>Maria Anders</td>
</tr>
</table>
推荐阅读
- c - 父进程终止后如何杀死所有子进程?
- ruby-on-rails - 设计登录总是返回“无效的电子邮件或密码”,即使它们是正确的
- javascript - 即使关闭并重新打开浏览器,如何使用 Java HTTPSession 在我的站点上保持会话打开?(不是 PHP)
- php - 未捕获的错误:调用未定义的函数 sql_regcase()
- arrays - 无法访问 JSON 对象内的数组/属性
- powershell - Powershell Core - 如何使 linux 文件类型可执行
- python - handson-ml-master 笔记本的问题
- android - 使用 inputType 作为 textPassword 时如何更改 TextInputEditText 提示字体
- amazon - lightail 应用程序未出现在 aws 控制台上
- javascript - 如何在 forEach 循环中每秒运行一次 setTimeout?