0

我有一个母版页,并且我有一个来自这个母版页的内容页。我必须为这个内容页使用不同的 CSS 作为正文标签吗?我怎样才能做到这一点?

这是我的母版页的 css

body, div, ul, ol, li, p, h1, h2, h3, span, pre, a, img, blockquote, table, tbody, tfoot, thead, tr, th, td, pre, code { 
margin:0px; padding:0px; border:0 none; outline:0; vertical-align:baseline;}

我不希望我的内容页面使用这个 css 代码。我怎么能做到这一点?

4

3 回答 3

1

您可以在包含 CSS 的母版页中创建一个控件。如:

<%@ Master Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 
    1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server" >
    <title>Master page title</title>
</head>
<asp:contentplaceholder id="CSS" runat="server">
<style type="text/css">
body, div, ul, ol, li, p, h1, h2, h3, span, pre, a, img, blockquote, table, tbody, tfoot, thead, tr, th, td, pre, code { 
margin:0px; padding:0px; border:0 none; outline:0; vertical-align:baseline;}
</style>
<body>

</body>
</html>

然后,您可以在覆盖主页面的客户端页面上放置一个内容控件,并忽略其余页面上的内容控件(它们将继承默认值)。

我建议使用单独的 CSS 文件而不是直接嵌入它,但您也可以轻松完成。

于 2011-09-21T23:32:42.420 回答
1

据我所知,您可以这样做的唯一方法是为此特定内容页面创建第二个母版页。

我建议从母版页中删除样式并根据需要将它们包含在每个内容页面中,您的母版页应该同样适用于每个页面,而不会造成任何问题

于 2011-09-21T15:14:18.220 回答
0

抱歉,但我建议您将此 CSS 包含在您需要的页面中,而不是母版页中,因为您不希望在每个页面中都包含它...我想这不是您期望的答案,但这就是 CSS 的方式是工作:S

于 2011-09-21T15:12:24.877 回答