CSS 标题 1 背景图片

标签 css background-image html-heading

我这里有这张图片,我想将其作为 h1 的背景图片 http://inauguralseason.com/wp-content/themes/twentyeleven/images/wehavelaunched.png

我的问题是如何让左边的部分出现?这是我当前的 CSS 代码

.homeBottom h1 {
    background-image: url("http://inauguralseason.com/wp-content/themes/twentyeleven/images/wehavelaunched.png");
    color: #FFFFFF;
    height: 36px;
    margin-left: -50px;
    width: 589px;
}

我原以为使用 margin-left:-50px 会奏效,但事实并非如此。

最佳答案

您指定了 height: 36px; 但您的图像是 86px 高。将高度更改为 86px,您将看到整个内容。

如果 36px 是正确的高度,您可以改为更改背景位置。

background-position: left bottom;

关于CSS 标题 1 背景图片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12558618/

相关文章:

html - 如何显示标题文本后面的背景图像?

css - 将背景添加到 h1,仅在合适的空间上

javascript - 扩展列表不移动容器/页脚

css - 与媒体查询一起使用的好的分辨率值是多少?

html - 限制文本区域

node.js - 有没有用于从图像中删除背景的 npm 包?

html - 在网页设计中是否应该不惜一切代价避免 <br/> 和 <hr/> ?

css - 随着窗口大小减小 CSS 从左侧截断图像

html - 使用 CSS 在较小的屏幕分辨率下删除 div 左侧和右侧的空白

html - 当文档大纲中的位​​置不可知时使用哪个标题级别?