CSS Banner图片不会仅显示纯白色背景

时间:2019-02-11 08:57:01

标签: css

我的CSS中有此代码,仅显示纯白色图像。谁知道如何显示它?

结果: enter image description here

横幅图片: enter image description here

/* style.css */

.fixed {
  background-image: url('img/bg.png') no-repeat center center fixed;
  display: table;
  height: 100%;
  position: relative;
  width: 100%;
  background-size: cover;
}
<!-- index.html -->

	<div class="fixed">
	<div class="fixed-overlay">
	<div class="landing-text">
		<h1>A lifetime work for "fish"</h1>
	</div>
	</div>
</div>

2 个答案:

答案 0 :(得分:1)

您使用了错误的CSS属性。

代替background-image: url('img/bg.png') no-repeat center center fixed;

image

中删除关键字background-image

尝试:background: url('img/bg.png') no-repeat center center fixed;

快乐编码☻

答案 1 :(得分:0)

尝试使用单独的属性

.fixed {
  background-image: url("https://i.stack.imgur.com/Dmnd8.png");
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  height: 100px;
  display: table;
  position: relative;
  width: 100%;
}
<div class="fixed">
  <div class="fixed-overlay"></div>
</div>