0

I was hoping someone may be able to help out with an issue.

I have a site that is accessed through a root domain (originalDomain.com) and the CSS is linked as below.

<link href="../../Styles/Css/style.css" rel="stylesheet" type="text/css" />

This all works fine

However I can also access this site on a different domain. Rather than the absolute root of the domain this one is accessed at newDomain.com/login. This still points to the files at the location of the original domain but because of the /login is unable to locate the CSS file. I assume the ../../ takes it to newdomain.com rather than newdomain.com/login.

Is there an easy way to have a single CSS reference without any back end code changes that will allow the CSS to be successfully referenced at both of the above scenarios.

I hope this makes sense.

Any help is greatly appreicated.

4

2 回答 2

2

给出绝对路径而不是相对路径

<link href="/path/to/css/style.css" rel="stylesheet" type="text/css" />

注意第一个字符是/(斜线)

于 2012-01-24T11:00:51.107 回答
0

如果您的<head></head>标签包含 runat="server" 您可以简单地将其指定为:

<link rel="stylesheet" type="text/css" href="~/CSS/Style.css" media="screen" />

取自这里

于 2012-01-24T11:04:59.387 回答