最佳答案
我试图显示一个有4列的表,其中一列是一个图像。 下面是快照:-< img src = “ https://i.stack.imgur.com/Rm1CC.jpg”alt = “ enter image description here”>
我想垂直对齐文本的中心位置,但不知何故,CSS 似乎不工作。 我已经使用了启动响应表。 我想知道为什么我的代码不工作,什么是正确的方法使它工作。
下面是表的代码
CSS
img {
height: 150px;
width: 200px;
}
th, td {
text-align: center;
vertical-align: middle;
}
超文本标示语言
<table id="news" class="table table-striped table-responsive">
<thead>
<tr>
<th>Name</th>
<th>Email</th>
<th>Phone</th>
<th>Photo</th>
</tr>
</thead>
<tbody>
<?php
$i=0;
foreach ($result as $row)
{ ?>
<tr>
<td>
<?php echo 'Lorem Ispum'; ?>
</td>
<td>
<?php echo 'lrem@ispum.com'; ?>
</td>
<td>
<?php echo '9999999999'; ?>
</td>
<td>
<?php echo '<img src="'. base_url('files/images/test.jpg').'">'; ?>
</td>
</tr>
<?php
}
?>
</tbody>
</table>