样式表在一个网页中不起作用
母版页中的样式表不适用于 ASP.NET 应用程序的一个网页,但适用于另一网页。
Style sheet in master page is not working for one web page of asp.net application but it works for another web page.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
如果您从母版页引用 css 文件,您应该确保它具有绝对路径,这样它就可以在任何地方工作。 例如:
这里需要注意的重要一点是 head 标签具有 runar="server" 属性,并且我使用波浪号(“~”)指定完整的虚拟路径。
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. For example:
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 ("~").
没有包含任何风格元素吗? 它是否被覆盖(它们是层叠样式表)? 它有正确的 CSS include 语句吗?
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 定义为:
并将您的页面设置为相同水平,像这样:
Are your pages in different levels of folders ?
For example,
in this scenario you should define your css in masterpage as :
And take your pages to same level, like that :
如果您使用更新面板,在某些情况下,AJAX 工具包控件的样式可能会丢失。 要解决此问题,您需要将类项的全名放入样式表中,而不是让工具包处理此问题。
还要确保尽可能使用相对 url,这样如果文件移动,它就不会丢失其映射。
If you are using update panels there are some cases where the styling may be lost for AJAX toolkit controls. To fix this you need to put hte full name of hte class items into the stylesheet instead of letting hte toolkit handle this.
Also be sure to use a relative url where possible so that if a file moves it won't loose it's mapping.
使用 Firebug 或 调试栏,这些工具将向您显示每个元素上使用的所有样式,以便您可以看到它正在使用哪些样式表以及没有使用哪些样式表。
另外,当您构建时,请检查有关它无法引用的样式表等的任何警告。
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.
Also, when you build check for any warnings about stylesheets that it can't reference etc.
这可能是文件夹的权限问题...如果您拒绝用户=“?” 在你的网络配置中..确保你有一个允许用户在你有你的样式表的文件夹
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