简体   繁体   English

样式表无法在一个网页上运行

[英]Style Sheet is not working in one web page

母版页中的样式表不适用于asp.net应用程序的一个网页,但适用于另一网页。

If you are referencing a css file from a master page you should ensure it has an absolute path, that way it will work everywhere. 如果要从母版页引用css文件,则应确保它具有绝对路径,这样它将可以在任何地方使用。 For example: 例如:

<head runat="server">
    <link type="text/css" rel="stylesheet" href="~/_styles/mystylesheet.css" />
</head>

The important thing to note here is that the head tag has the runar="server" attribute and that i am specifying the full virtual path using a tilde ("~"). 这里要注意的重要事情是head标签具有runar =“ server”属性,并且我正在使用波浪号(“〜”)指定完整的虚拟路径。

it could be a permission issue on the folder... if you have deny users="?" 这可能是文件夹上的权限问题...如果您拒绝用户=“?” in your web config.. make sure you have an allow users on the folder where you have your style sheets 在您的网络配置中。确保在样式表所在的文件夹中有一个允许用户

Are none of its style elements being included? 没有包含任何样式元素吗? Is it being over ridden( they are Cascading Style Sheets)? 是否被超越(它们是层叠样式表)? Does it have the correct CSS include statement? 它是否具有正确的CSS include语句?

Are your pages in different levels of folders ? 您的页面在不同级别的文件夹中吗?

For example, 例如,

..\\main.css .. \\ main.css

..\\folder1\\MasterPage.master .. \\ folder1 \\ MasterPage.master

..\\folder1\\css_working.aspx .. \\ folder1 \\ css_working.aspx

..\\folder1\\folder2\\css_not_working.aspx .. \\ folder1 \\ folder2 \\ css_not_working.aspx

in this scenario you should define your css in masterpage as : 在这种情况下,您应该在母版页中将CSS定义为:

<link rel="stylesheet" type="text/css" href="../main.css" />

And take your pages to same level, like that : 然后将您的页面提升到同一水平,如下所示:

..\\main.css .. \\ main.css

..\\folder1\\MasterPage.master .. \\ folder1 \\ MasterPage.master

..\\folder1\\css_working.aspx .. \\ folder1 \\ css_working.aspx

..\\folder2\\css_not_working.aspx .. \\ folder2 \\ css_not_working.aspx

If you are using update panels there are some cases where the styling may be lost for AJAX toolkit controls. 如果使用更新面板,则在某些情况下AJAX工具包控件的样式可能会丢失。 To fix this you need to put hte full name of hte class items into the stylesheet instead of letting hte toolkit handle this. 要解决此问题,您需要将HTE类项目的全名放到样式表中,而不是让HTE工具包来处理。

Also be sure to use a relative url where possible so that if a file moves it won't loose it's mapping. 另外,请确保在可能的情况下使用相对网址,以便文件移动时不会丢失其映射。

Use Firebug or Debug Bar , these tools will show you all the styles being employed on each element, so you can see what stylesheets it is using and which ones it is not. 使用FirebugDebug Bar ,这些工具将向您显示每个元素上使用的所有样式,因此您可以查看正在使用的样式表和未使用的样式表。

Also, when you build check for any warnings about stylesheets that it can't reference etc. 另外,在构建时,请检查有关样式表无法引用的任何警告等。

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

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