从 css 请求 App_Themes 图像
通常,当主题文件夹中有图像或 css 之类的项目时,它们会得到很好的解析,并且 url 会省略 App_Themes 部分。但是我注意到,对于在来自同一主题的 css 中设置的一些背景图像,App_Themes/MyTheme/someimage.gif 的请求已完成。导致明显的404响应。
这是怎么发生的?对我来说更重要的是:我能做些什么来摆脱这个问题,因为它会损害我的表现。
Normally when you have items like images or css in the theme folder they get nicely parsed and the url omits the App_Themes part. However I noticed for some background images, set in the css which comes from the same theme, that a request with the App_Themes/MyTheme/someimage.gif gets done. Resulting in an obvious 404 response.
How does this happen? And more important to me: what can I do to get rid of this as it hurts my performance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
CSS 文件中的路径始终相对于 CSS 文件。因此,如果您从 CSS 文件(位于主题文件夹中)设置背景图像,则图像 URL 是相对于 CSS 文件的。
如果您不希望出现这种行为,则可以使用“../../images/myImage.gif”或“/appName/images/myImage.gif”引用图像(假设您的图像位于“images”中)您的网络应用程序的文件夹。
Paths in CSS files are always relative to the CSS file. So if you set a background image from a CSS file (located in the theme folder) then the image URL is relative to the CSS file.
If you don't want that behaviour, then you can reference the image using "../../images/myImage.gif" or "/appName/images/myImage.gif" (assuming your image is in the "images" folder of your web app.
你还没有回答你自己的问题吗?
如果 myimage.gif 与 .css 文件不在同一文件夹中,则需要根据 M4N 的响应指定其相对路径。
Haven't you answered your own question?
if myimage.gif is not located in the same folder as your .css file, you'll need to specify its relative path as per M4N's response.