html - 如何在使用位置 :relative 时增加图像的宽度

标签 html css image

代码如下:

<table border="1" cellpadding="2" cellspacing="2" height="250">
<tbody>
    <tr>
        <td>
            <div style="background: url('image path goes here';); width: 300px; height: 250px; position: relative;">
<p style="width: 180px; font-size: 12px; margin-top: 35px; position: absolute;">My TEXT goes here....</p>
        </td>
    </tr>
</tbody>
</table>

现在,我需要增加图像的宽度或需要向左缩进图像。

我该怎么做?

我试过直接给出宽度..但它不起作用...

任何意见或建议将不胜感激..

最佳答案

您正在使用图像作为父 div 的背景。如果你只想改变图像的大小,你应该使用 img 标签。类似于下面的示例

    <table border="1" cellpadding="2" cellspacing="2" height="250" width="300">
<tbody>
    <tr>
        <td>
            <div >
                <img style="float:left;" src="http://www.gravatar.com/avatar/03bc7f86de865926a1cb5036198d00a0?s=32&amp;d=identicon&amp;r=PG" width="150px" height="125px" /></div>
<p style=" display: block; width: 280px; font-size: 12px; margin-top: 35px; position: relative;">We understand you want to choose benefits that suit you and your life. And we regularly review things so we're always offering benefits you say you want to see.</p>
        </td>
    </tr>
</tbody>
</table>​​​​​​​​​​​​​​​

关于html - 如何在使用位置 :relative 时增加图像的宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13817477/

相关文章:

jquery - 动态添加按钮到数据表行

css - 如何使用带样式组件的默认 Bootstrap 类?

java - 找不到在 Scene Builder 中添加的 CSS StyleSheet

jquery - @media 屏幕查询在 jQuery 操作后似乎变得不确定?

image - SVG 中的 <image> 中的 VueJS 外部引用没有 vueloader?

image - 是使用图像还是 CSS 来尽可能保持网页或应用程序的性能更好?

html - 整个 HTML block 没有接收 CSS 类样式

javascript - 使用未定义的 Node js "TypeError: Cannot read property ' render' 运行 .js 文件时出错”

html - 无法从 Bootstrap 菜单中删除黑条以显示我的菜单更改

image - 是否可以使用 opencv 在同一窗口上显示黑白和彩色图像?