html - 强制图像在表格单元格中溢出

标签 html css

如何在不扩展单元格的情况下强制图像在表格单元格中溢出?

编辑:

抱歉,我会提供更多信息。这是表格:

<table class="content">
    <col width="200px" />
    <col width="560px" />
    <col width="200px" />
    <tr>
        <td colspan="3" class="logo"></td>
    </tr>
</table>

CSS:

.logo
{
    height: 120px;
    background: url('img/wallpaper.png') center;
}

我以为会有一个简单的解决方案...

最佳答案

如果您使用 <img>标记而不是背景图像,您可以使用 position: absolute; 将其从文档流中删除

html

<td class="logo">
    <img src="img/wallpaper.png">
</td>

CSS

.logo img {
    position: absolute;
}

这将使图像溢出单元格,但会产生您需要处理的其他副作用。相应地更新顶部或底部以将图像保持在原位。

调整后的 css

.logo img {
    position: absolute;
    top: 15px;
}

查看 http://jsfiddle.net/QMNRp/1/

关于html - 强制图像在表格单元格中溢出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15524191/

相关文章:

html - 将字符对齐到html中的固定宽度

html - 为什么将图像添加到表格单元格会导致它在其周围放置填充

javascript - 导航切换仅在最小化窗口时可见

javascript - 单击任意位置以隐藏滑动页脚

javascript - 带悬停的 CSS3 圆圈

jquery - 从右到左调整jquery中的div

javascript - Rails 在 html 公共(public)文件中包含 js

html - 链接背景图像在加载之间消失

css - React Header 计算

html - 如何缩放具有相同位置但位于其他 svg 元素之上的 svg