html - 图像未定位到中心

标签 html css twitter-bootstrap

我想在单元格中心的表格中显示图像,但这就是我得到的。我的图像覆盖了整个单元格,而不是放在单元格的中心。我正在使用来自 Bootstrap 文件的 img-responsive 类用于图像和表响应类。 此外,每当我加载页面时,我都会随机获得以下输出之一,而代码绝对没有变化。 为什么会这样?? 在这两种情况下,图像似乎都位于列的左侧,我该如何更正它以使图像位于中心。 以下是代码

<div class="table-responsive inside_content ps-container" style="margin-bottom: 50px">
<style>
    th,td{
        text-align: center;
    }
</style>
<table id="event" class="table table-striped table-responsive">
    <thead>
        <tr>
          <th>Serial No.</th>
          <th>Section</th>
          <th>TimeStamp</th>
          <th>Archive_Status</th>
          <th>Event Picture</th>
          <th>Actions</th>
        </tr>
    </thead>
    <tbody>
                    <tr>
            <td>
                test1                </td>
            <td>
                Event3                </td>
            <td>
                2015-01-08 19:41:45                </td>
            <td>
                0                </td>
            <td>
                <a class="event_group1" href="http://localhost/IOCLALL/IOCLbackend/../IOCLfrontend/images/events/WWW.YTS_.RE_.jpg">
                    <img alt="No Image" class="img-responsive" style="max-width:145;max-height: 208px" src="http://localhost/IOCLALL/IOCLbackend/../IOCLfrontend/images/events/WWW.YTS_.RE_.jpg" />
                </a>
            </td>
            <td>
                <a href="http://localhost/IOCLALL/IOCLbackend/index.php/start/deleteevent?id=2" onclick="return del();"><span class="fa fa-fw fa-trash" ></span></a>&nbsp;&nbsp;
                <a href="http://localhost/IOCLALL/IOCLbackend/index.php/start/editevent?id=2" onclick=""><span class="fa fa-fw fa-edit" ></span></a>
            </td>
        </tr>



    </tbody>
</table>

</div>

最佳答案

您必须像对待 P 一样对待 TD, 添加一个 text-align:centerTD 和一个 display:inline-block 到图像

<td style="text-align: center;">
    <img style="display: inline-block;" />
</td>

关于html - 图像未定位到中心,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27842962/

相关文章:

javascript - 如何在浏览器中通过 POST 请求加载外国图片?

html - 我最初如何在我的单页应用程序中隐藏 Bootstrap Accordion 内容?

html - 代码在 Codecademy 上完美呈现,但在 Firefox 中的本地主机上却不完美,有什么不同?

html - 引用表元素

javascript - 从 Bootstrap typeahead 和 JSON 制作可点击的结果列表

javascript - bootstrap-modal.js 在 Bootstrap 3 中损坏

html - 为什么 "border-top:none"会把我其余的 css 放错地方?

html - 为什么这个高度为 100vh 的 div 没有覆盖整个视口(viewport)?

html - 嵌套 HTML 元素的最大级别

html - 在较小的屏幕尺寸上重新排列不同列中的卡片