google-chrome - Chrome 不渲染 svg 图像
问题描述
我在渲染 svg 图像时遇到问题,但仅限于 Chrome(FF、IE、Edge 都可以)。我只能看到图像中的文本,但图像等没有任何背景颜色。我需要全屏显示图像,这是我的代码。有人可以帮助我,chrome的问题在哪里以及如何解决?
<!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>
解决方案
没有更多信息,我们只能说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>
推荐阅读
- c++ - 内存查看器,填充值
- scala - 如何验证 scala 语法?
- python - 如何将 Python 数字列表转换为 json 对象
- android - Android 在 lambda 函数中获取资源 ID 返回错误的 ID
- python - Conda: concurrent.futures.process.BrokenProcessPool: 进程池中的一个进程在未来运行或挂起时突然终止
- python-3.x - TensorFlow Estimator 以 Web 格式保存 (tfjs)
- javascript - 使用数组列表并在 React 中访问其元素
- amazon-web-services - AWS 上的 Neo4J 在线备份错误 - 无法使用可用策略运行备份
- vue.js - 为什么从不调用 beforeLeaveRoute?
- python - 仅计算数据框中没有 NaN 值的数据行的平均值