css - 表格内的按钮元素显示在 div 元素中的文本上方
问题描述
我创建了一个粘性标题,用于使用 jquery 过滤 html 表中的数据。我遇到的问题是粘性元素和表格中的元素的对齐方式。
我尝试过使用 z-index,但没有帮助。并且更改边距属性也会将边距应用于粘性元素。
<style>
body,th,td
{
font-family: serif;
font-size: 20px;
text-align: center;
}
table
{
width: 125%;
overflow: auto;
margin: 50px auto;
}
caption
{
text-align: center;
margin: 10px auto;
font-family: serif;
font-size: 28px;
font-style: italic;
}
th,td
{
background-color: white;
border: 2px solid black;
height: 50px;
}
button
{
margin-left: 2px;
margin-right: 2px;
}
#srch_bar
{
position: -webkit-sticky;
top: 5px;
position: sticky;
margin-top: 10px;
float: right;
width: 100%;
height: 50px;
background-color: white;
}
#srch_bar select
{
outline: none;
border: none;
padding: none;
}
#LSRCH
{
text-transform: uppercase;
}
</style>
<script>//only the needed part is added
for(j=0; j<res_stock.length; j++)
{
var trow = '<tr>';
trow += '<td>' + res_stock[j].slno + '</td>';
trow += '<td>' + res_stock[j].lotNo + '</td>';
trow += '<td>' + res_stock[j].parName + '</td>';
trow += '<td><button class="glyphicon glyphicon-forward btn-success btn-sm" id="UPD' + res_stock[j].slno + '"></button><button class="glyphicon glyphicon-edit btn-warning btn-sm" id="EDT' + res_stock[j].slno + '"></button><button class="glyphicon glyphicon-trash btn-danger btn-sm" id="DEL' + res_stock[j].slno + '"></button></td>';
trow += '<td>' + res_stock[j].gMtr + '</td>';
trow += '<td>' + res_stock[j].gWt + '</td>';
trow += '<td>' + res_stock[j].gActWt + '</td>';
trow += '<td>' + res_stock[j].gRPWaWf + '</td>';
trow += '<td>' + res_stock[j].gGF.substring(res_stock[j].gGF.indexOf('G')+1,res_stock[j].gGF.indexOf('F')) + '</td>';
trow += '<td>' + tone_stretcher(res_stock[j].tone) + '</td>';
trow += '</tr>';
$(trow).appendTo('#stk_tbl');
}
该表是使用 jquery 由 json 文件中的动态数据生成的。问题是我在表格中有三个按钮,用于与该特定行相关的选项。当我滚动表格时,按钮显示在粘性元素上方。相反,它应该放在粘性元素的后面。
解决方案
推荐阅读
- button - 如何使用带有按钮的 html 将随机生成的数字插入电子邮件
- python - 如何在Python中每四位用逗号格式化一个数字?
- reactjs - 如何在反应查询中进行依赖突变?
- ios - iOS随机导航问题,每次点击按钮都没有反应
- javascript - Angular 应用程序的 Ngmodules 文件夹中的某些文件被随机删除并出现错误?
- scala - 下面的凿子语句是如何解码的?
- php - post 405 方法不允许 php forn
- java - JComboBox 自定义单元格渲染器 - 如何获取组合的 isEnabled() 状态?
- python - 在 Jupyter Notebook 中执行高斯朴素贝叶斯时出错
- android - VSCode,Flutter - 红色下划线