对齐图像按钮不起作用?

时间:2015-06-10 04:50:20

标签: html css

我有一张桌子。我的问题是两个图像按钮应该对齐。问题在于,无论我尝试第二张图像总是在第一张图像下。我希望这两个图像水平对齐。

这是我的表格代码:

public function dataview($query)
{
  $stmt = $this->db->prepare($query);
  $stmt->execute();

  if($stmt->rowCount()>0)
  {
    while($row=$stmt->fetch(PDO::FETCH_ASSOC))
    {
      ?>
        <tr>
          <td><?php echo($row['user_id']); ?></td>
          <td><?php echo($row['username']); ?></td>
          <td><?php echo($row['password']); ?></td>
          <td>
            <a href="edit.php?user_id=<?php echo ($row['user_id']); ?>"><input name="image" type="image" value="edit"><img src="image/EDIT.png" class="img-responsive" width="30px"></a>
            <a href="delete.php?user_id=<?php echo ($row['user_id']); ?>"><input name="image" type="image" value="delete" onClick="return confirm('Are you sure you want to delete?');"><img src="image/DELETE.png" class="img-responsive" width="30px"></a>
          </td>
          <!--<td><a href="DELITEM.PHP?user_id=<?php echo ($row['user_id']); ?>" <img src="image/DELETE.png" width="25" onClick="return confirm('Are you sure you want to delete?');">Delete</a></td>-->

        </tr>
      <?php
    }
  }
  else
  {
    ?>
      <tr>
        <td>Nothing here...</td>
      </tr>
    <?php
  }

}

?>

1 个答案:

答案 0 :(得分:0)

为两个锚标记提供左侧浮动样式。确保td中有enogh空间以适合这两个图像。

 <a style="float:left" href="edit.php?user_id=<?php echo ($row['user_id']); ?>"<input name="image" type="image" value="edit"><image src="image/EDIT.png" class="img-responsive" width="30px"></a>

 <a style="float:left" href="delete.php?user_id=<?php echo ($row['user_id']); ?>"<input name="image" type="image" value="delete" onClick="return confirm('Are you sure you want to delete?');"><image src="image/DELETE.png" class="img-responsive" width="30px"></a>