Chrome无法呈现svg图像

问题描述 投票:0回答:1

我在渲染svg图像时遇到问题,但仅在Chrome中有效(FF,IE,Edge可以)。我只能从图像中看到文本,但是从图像等中看不到任何背景色。我需要全屏显示图像,这是我的代码。有人可以帮我吗,铬的问题在哪里以及如何解决?

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body, html {
  height: 100%;
  margin: 0;
}

.bg {
  /* The image used */
  background-image: url("bg.svg");

  /* Full height */
  height: 100%; 

  /* Center and scale the image nicely */
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
}
</style>
</head>
<body>
<div class ="bg"> </div>



</body>
</html>
google-chrome svg fullscreen
1个回答
0
投票

没有更多信息,我们只能说是your code works

[我所做的就是将URL从您的svg文件更改为公共占位符svg图像。如您所见,显示此文件有零个问题。

body, html {
  height: 100%;
  margin: 0;
}

.bg {
  /* The image used */
  background-image: url("https://placeholder.pics/svg/300");

  /* Full height */
  height: 100%; 

  /* Center and scale the image nicely */
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
}
<div class="bg"> </div>
© www.soinside.com 2019 - 2024. All rights reserved.