我正在尝试制作Web应用程序,我需要在标题栏中添加一个带有名称的图标。
我正在使用MVC中的空项目制作Web应用程序,其中包含Web表单。我正在使用Visual studio 2017进行编码。到目前为止,我已经尝试了如下布局。
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<link href="~/Content/nav.css" rel="stylesheet" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="icon" type="image/svg" href="~/Content/img/download.png" />
<script src="~/Scripts/layout.js"></script>
<title>@ViewBag.Title</title>
</head>
<body>
<navbar>
<div class="topnav" id="myTopnav">
<a href="Home/Index">Home</a>
<a href="Login/login">Login</a>
<a href="Payment/Payment"> Payment </a>
<a href="Register/register">Customer Registration</a>
<a href="javascript:void(0);" class="icon" onclick="myfunction()">
<i class="fa fa-bars"></i>
</a>
</div>
<div>
@RenderBody()
</div>
</navbar>
</body>
</html>
我试图在标题之前链接图像,但它转错了。由于我是MVC的新手,请给我一些方法将图标添加到标题栏。
您正在寻找的称为网站图标。您可以从 png 或其他任何东西生成它,然后将其包含在您的页面中,如下所示:
<link rel="icon" href="/favicon.ico" type="image/x-icon">
这是一个网站图标生成器(众多之一(:https://www.favicon-generator.org/
问题在于以下代码:
<link rel="icon" type="image/svg" href="~/Content/img/download.png" />
您指定类型是image/svg
,而它是一个image/png
。
确保文件夹中存在 png 图像Content/img
。