【发布时间】:2015-02-26 19:24:26
【问题描述】:
在将我的 MVC 5 项目发布到 IIS 7 时,我在让图像正常工作时遇到了一些问题。我有一个像下面这样的主体样式,它似乎通过显示白色背景而不是图像而失败(它完全跳过了灰色)
body {
background-color: grey;
background: transparent url("Images/Background.png") no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
background-repeat: no-repeat;
font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
height: 100%;
}
我打开了 chrome 开发工具并查看了图像的实际链接并手动添加了“/”然后将其删除,图像显示正常,但刷新失败。除了下面定义的 404 错误外,我在控制台中没有收到任何错误。
我也尝试了以下版本(其中一些比其他版本更明显的失败)
- Images/Background.png(无错误)
- /Images/Background.png(404错误)
- ~/Images/Background.png(404 错误)
- ~Images/Background.png(404 错误)
后 3 个抛出错误如下:
- http://10.96.90.65/Images/Background.png 404 (Not Found)
- http://10.96.90.65/SITE/Content/~/Images/Background.png 404 (Not Found)
- http://10.96.90.65/SITE/Content/~Images/Background.png 404 (Not Found)
我适用的虚拟文件结构看起来像
- /内容
- /内容/图片/
- /内容/主题/
- /Content/*.css
- /图片/
我正在使用 Visual Studio 2012 和 IIS 7 编辑:图片在 Internet Explorer 中加载,但不是在 Chrome 中
【问题讨论】:
-
它“完全跳过灰色”,因为您将其设置为灰色,然后在以下行中将其设置为透明。
-
哦。呃。接得好。但这只是次要问题。
-
是的,我想。只是想我会提到它,因为我注意到它。 :-)
标签: css asp.net-mvc image visual-studio-2012 iis-7