gpt4 book ai didi

css - 在 Release模式下找不到字体和图像

转载 作者:行者123 更新时间:2023-11-28 16:58:43 25 4
gpt4 key购买 nike

我的 Web 应用程序包含一些内容(图像、字体等)。我试着看看它在 Release模式下是如何工作的,所有布局崩溃都会导致字体和图像“未找到”。

此行为的原因是什么以及如何解决?

我发现了什么 - 我的图像位于文件夹 Content/images/ 中。在 Debug模式下,应用程序通过该路径查找图像,但在 Release模式下,它会跳过文件夹 Content/ 并尝试查找 images/

  body {
margin: 0 auto;
font-family: Arial;
font-size: 12px;
background: url(images/main_bg.jpg) repeat center top fixed;
background-size: 100%;
vertical-align: top;
font-weight: normal;
}

这是我在 CSS 中使用图像的方式

bundles.Add(
new StyleBundle("~/layout-styleNew")
.Include("~/Content/bootstrap/css/*.css")
.Include("~/Content/bootstrap/flatly/*.css")
.Include("~/Content/helpful.css")
.Include("~/Content/styleNew.css")
.Include("~/Content/css/ToastMsg/css/*.css")
.Include("~/Content/css/jquery-ui/*.css"));

<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title>@this.ViewBag.Title</title>

@Scripts.Render("~/layout")
@Styles.Render("~/layout-styleNew")
@RenderSection("head", false)

</head>

最佳答案

你的问题是现实路径。

在你的 CSS 中你有:

background: url(images/main_bg.jpg) repeat center top fixed;

这意味着客户端正在寻找与 CSS 位于同一文件夹中的名为“images”的文件夹。在调试中,这是找到 CSS 文件的 Content 文件夹的子文件夹。

但是当您打包时,客户端会在根文件夹中看到 CSS,因此会创建一个相对于根文件夹的路径。

您需要为您的包提供一个与真实路径足够相似的名称,以便正确解析相对路径。也许是“Content/AllStyles”?

关于css - 在 Release模式下找不到字体和图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31649180/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com