我在表列表中显示数据库中的记录。另外,我在每行中都有一个跟踪按钮,如果任何用户单击跟踪按钮,则会为特定用户打开一个包含详细信息的弹出窗口。
或任何其他想法来解决这个问题?
我试图用这样的东西
<table>
<thead><tr><th></th></tr></thead>
<tbody>
<tr><td></td></tr>
<div style="display:none">
<table>
<thead><tr><th></th></tr></thead>
<tbody>
<tr><td></td></tr>
</tbody>
</table>
</div>
</tbody>
</table>
完整代码
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<table border="1">
<thead>
<tr>>
<th>Name</th>
<th>Products</th>
<th>Qty</th>
<th>Order Id</th>
<th>Mobile </th>
<th>Shipping address</th>
</tr>
</thead>
<tbody>
<?php $n=1;
foreach ($cust_personal as $row)
{ $encryption_id=base64_encode($this->encryption->encrypt($row->o_id));//encrpt the id
?>
<tbody>
<tr>
<td><?php echo $n;?></td>
<td><?php echo $row->c_firstname;?> <?php echo $row->c_lastname;?></td>
<td><?php echo $row->o_product_brandname;?></td>
<td><?php echo $row->o_product_qty;?></td>
<td><?php echo $row->o_order_no;?></td>
<td><?php echo $row->c_mobileno;?></td>
<td><?php echo $row->c_s_address;?></td>
<td> <a href="javascript:void(0)" class="table_icon pending" onclick="approve(this)" data-id="<?=$row->o_id;?>"> <span>Pending</span></a>
<a href="<?php echo site_url('Customer_control/get_customer_view?key='.$encryption_id)?>" class="table_icon view">View</a>
<a href="javascript:void(0)" class="table_icon archive" onclick="followup(this)" data-id="<?=$row->o_id;?>">Followup</a>
</tr>
<div id="popup-<?=$row->o_id;?>" style="display: none;" class="class="view_popup_profile">
<div class="profile_content">
<div class="profile_header clearfix">
<table border="1">
<thead><th>sub</th></thead>
<tbody><tr><td>maths</td></tr></tbody>
</table>
</div></div>
</div>
<?php } $n++; ?>
</tbody>
</table>
<script type="text/javascript">
function followup(obj)
{
var id = $(obj).data('id');
//console.log(id);
$("#popup-"+id).show();
}
</script>
</body>
</html>
这是我得到的输出。
为什么需要嵌套表,因为当我添加以下代码并单击“跟进”按钮时,我会在全屏模式下看到弹出窗口。
</tr>
<div id="popup-<?=$row->o_id;?>" style="display: none;">
<!--more details here-->
</div>
</tbody>
</table>
如果我在弹出窗口中添加了一个表格以显示以下列表,则该表格不起作用。
</tr>
<div id="popup-<?=$row->o_id;?>" style="display: none;">
<table border="1">
<thead><th>sub</th></thead>
<tbody><tr><td>maths</td></tr></tbody>
</table>
</div>
</tbody>
</table>
CSS
.view_popup_profile {
position: fixed; /* Stay in place */
z-index: 9; /* Sit on top */
left: 0;
top: 0;
width: 100%; /* Full width */
height: 100%; /* Full height */
overflow: auto; /* Enable scroll if needed */
background-color: rgb(0,0,0); /* Fallback color */
background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
-webkit-animation-name: fadeIn; /* Fade in the background */
-webkit-animation-duration: 0.4s;
animation-name: fadeIn;
animation-duration: 0.4s;
}
/* Modal Content */
.profile_content {
position: fixed;
top: 25%;
background-color: #fefefe;
width: 100%;
-webkit-animation-name: slideIn;
-webkit-animation-duration: 0.5s;
animation-name: slideIn;
animation-duration: 0.5s;
max-width: 922px;
margin: auto;
left: 0;
right: 0;
box-shadow: 0 0 15px rgba(0,0,0,.3);
}
/* The Close Button */
.profile_header {
padding: 1px 20px;
background-color: #fafafc;
color: white;
/* min-height: 58px; */
border-bottom: 1px solid #f7f7f7;
display: block;
width: 100%;
}
.profile_header:after {
content: '';
width: 0;
height: 0;
border-left: 17px solid transparent;
border-right: 17px solid transparent;
border-top: 16px solid #f7f7f7;
position: absolute;
}
.profile_body {
padding: 35px 50px;
}
.profile_footer {
padding: 0;
background-color: #fdfdfe;
color: #858585;
}
p{color: #000;}
/* Add Animation */
@-webkit-keyframes slideIn {
from {
top: -500px;
opacity: 0
}
to {
top:25%;
opacity: 1
}
}
@keyframes slideIn {
from {
top: -500px;
opacity: 0
}
to {
top:25%;
opacity: 1
}
}
@-webkit-keyframes fadeIn {
from {
opacity: 0
}
to {
opacity: 1
}
}
@keyframes fadeIn {
from {
opacity: 0
}
to {
opacity: 1
}
}
最佳答案
您当然可以制作嵌套表。使所有内容都像一张普通表,直到td
标记为止。在其中,制作表格标签和所有内容。首先,您要做的是缩进不良(我在JSFiddle中进行了整理)
这是表格的单元格的样子:
<td>
<table>
<thead>
<th>sub</th>
</thead>
<tbody>
<tr>
<td>maths</td>
</tr>
</tbody>
</table>
</td>
您也可以使用colspan和rowspan(其结果相似)来防止被复杂的设计所迷惑。
<tr>
<td rowspan = 2>10</td>
<td> 10 </td>
</tr>
<tr>
<th>sub</th>
</tr>
<tr>
<td>math>
</tr>
关于javascript - 我们可以在 `<tr></tr>`之后使用嵌套表吗?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/51717492/