没有出现在网站上的背景图像

时间:2014-11-19 11:48:29

标签: html

我正在尝试放置背景图片,但它没有出现。请指导。

    <header style="    background-image: url("header.png")";
"><p>Test</p>
        </header>

2 个答案:

答案 0 :(得分:1)

很明显,你有错字或错过了图像。您可以使用此代码段:

内联CSS:

<header style="width: 360px; height: 150px; background-image: url('http://placehold.it/360x150');">
  <p>Test</p>
</header>

外部CSS:

header {
  width: 360px;
  height: 150px;
  background: url("http://placehold.it/360x150");
}
<header>
  <p>Test</p>
</header>

答案 1 :(得分:0)

您有一些语法错误。此外,您必须为其设置高度。

<header style="background-image: url('http://img.bananity.com/media/512/512/bananities/8060a5cf4f9eae8ecff79720db58c2dfacf707344fcb.png'); background-size: cover; height: 400px; border: 1px solid red;">
    <p>Test</p>
</header>

相关问题