html - 如何将 SVG 文件添加到 html 或 CSS?
问题描述
正如你在这里看到的,我使用图像标签在我的 github 存储库中添加了一个 SVG,但是我看不到它,当我打开实时预览时,它只显示一个图像图标来代替我的实际徽标,我也尝试使用 CSS 添加文件,但它有同样的问题。
https://github.com/Alucard2169/Third.git这里是指向我的 GITHUB 存储库的链接,如您所见,我已将所有媒体文件放在媒体文件夹中。
.main_heading::before {
content: url(media/logo.svg);
display: block;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=default-width, initial-scale=1">
<meta charset="UTF-8">
<meta lang="en">
<link href="style.css" rel="stylesheet">
</head>
<body>
<header>
<div class="logo">
<img src="media/logo.svg">
</div>
<h1 class="main_heading">
A history of everything you copy
</h1>
<article class="main_content">Clipbord allows you to track and organize everything you copy instantly access your clipboard on all your devices.</article>
<bottoom class="ios">
Download for iOS
</bottoom>
<bottom class="mac">
Download for Mac
</bottom>
</header>
</body>
</html>
解决方案
在通过 .css 链接文件时url()
,您必须提供./
. 如下所示,但这仅适用于您的 html 文件位于媒体文件夹之外的情况。
.main_heading::before {
content: url(./media/logo.svg);
display: block;
}
推荐阅读
- raspberry-pi - 如何让 Raspberry Pi 成为 VoIP ATA 设备
- python - 将列表项转换为具有默认值的 dict 键
- bash - 为什么我的 cron 作业不能正常执行?
- python - 在 youtube-dl python 脚本中,我应该在哪里放置命令参数?
- javascript - 如何使用 javascript 在数据透视表中插入 :nth-child(x) 和 :before?
- shell - 向包装外壳脚本添加参数
- formatting - 有没有办法将 Zapier 格式化程序查找表从一个 zap 复制到另一个 zap?
- sql - 我对我的 SQL 连接感到困惑,因为它返回的结果与我的预期不同
- d3.js - D3JS:无法制作条形图以响应调整大小
- python - 如何在 Python 中读取包含 ObjectId 和 ISODate 的 json 文件?