简体   繁体   English

UI在localhost和托管网站(GoDaddy)中看起来有所不同

[英]UI looks different in localhost and hosted website(GoDaddy)

I hosted my ASP.NET MVC website in GoDaddy, but the appearance looks a little bit different. 我在GoDaddy托管了ASP.NET MVC网站,但外观看起来有些不同。 My navigation bar that originally is black (the default of MVC 5), turns into blue. 我原来是黑色的导航栏(MVC 5的默认设置)变成了蓝色。 And my background image is not showing. 而且我的背景图片没有显示。 What is the cause if this? 原因是什么? Someone please help. 有人请帮忙。 Thank you. 谢谢。 I already tried this for the background image: 我已经尝试过将其用作背景图像:

background-image: url('Image/BG30.png'); ---This one works in localhost, but not in hosted website ---这在本地主机上有效,但在托管网站上无效

background-image: url('/Content/Image/BG30.png'); ------Also works in localhost, but not in hosted website ------也可以在本地主机上工作,但不能在托管网站上工作

background-image: url('../Image/BG30.png'); --- This one doesn't work in both ---这两个都不起作用

Your reference to images in the css file must be relevant to the css file's location. 您对css文件中的图像的引用必须与css文件的位置有关。 It might be a good idea to use absolute paths instead of relative paths. 使用绝对路径而不是相对路径可能是一个好主意。 This article offers a good explanation of when and why to use absolute paths. 本文对何时以及为什么使用绝对路径提供了很好的解释。

Relative: /Content/Images/BG30.png 相对: /Content/Images/BG30.png

Absolute: http://www.example.com/Content/Images/BG30.png 绝对: http //www.example.com/Content/Images/BG30.png

Example: 例:

CSS File: example.com/Content/styles.css CSS文件:example.com/Content/styles.css

BG Image File: example.com/Content/Images/BG30.png BG图片文件:example.com/Content/Images/BG30.png

background-image: url('Images/BG30.png'); would work because / and ../ move the path up to the root and up one level respectively. 之所以起作用,是因为/../将路径向上移动到根目录和上一级。 background-image: url('Images/BG30.png'); would work regardless of the correlation between the location of the two files. 无论两个文件的位置之间的相关性如何,它都可以工作。

It seems as if the hosted approot path differs from your local path. 似乎托管的approot路径与本地路径不同。 Using an absolute path to your css file and absolute paths to your images (within the css file), can solve any confusion as to the location of the files. 使用css文件的绝对路径和图像的绝对路径(在css文件中)可以解决文件位置的任何混乱。

You should also make sure that you're uploading all the proper files (images included) to the proper location on the hosted site. 您还应该确保将所有正确的文件(包括图像)上传到托管站点上的正确位置。 Make sure that you're overwriting any existing files with the correct versions from the local path, this could be the cause of color issue. 确保使用本地路径中的正确版本覆盖所有现有文件,这可能是颜色问题的原因。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM