【发布时间】:2016-08-22 18:37:41
【问题描述】:
我正在尝试为网页制作警告横幅。我在面板内的 div 内使用标签,并在页面上声明了一些 css 样式。我不想在每个页面上声明这些样式,所以我将它们移到了我的 Site.css 文件(母版页使用)。当我这样做时,没有应用 css 样式的问题。母版页上的所有内容格式正确,但内容页中声明的控件格式不正确。
听听我在内容页面上的内容:
<asp:Content ID="Content2" ContentPlaceHolderID="ErrorMessages" runat="server">
<asp:Panel ID="WarningBanner" runat="server" CssClass="warningPanel" Visible="true">
<div class="warningDiv">
<asp:Label ID="testLabel" runat="server" Text="test" CssClass="warningLabel"></asp:Label>
</div>
</asp:Panel>
<style>
.warningPanel {
margin: auto;
width: 1000px;
background-color: red;
border: 10px solid red;
}
.warningLabel {
display: block;
color: white;
font-size: large;
}
.warningDiv {
margin-left: auto;
margin-right: auto;
text-align: center;
}
</style>
</asp:Content>
听听我在母版页上的内容:
<head runat="server">
...ext...
<link href="~/Content/Site.css" rel="stylesheet" />
...ext...
</head>
<body>
...ext...
<div id="body">
<asp:ContentPlaceHolder runat="server" ID="ErrorMessages" />
<div/>
...ext...
<body/>
这就是我的 Site.css 文件的样子:
html {
background-color: #e2e2e2;
margin: 0;
padding: 0;
}
.warningPanel {
margin: auto;
width: 1000px;
background-color: red;
border: 10px solid red;
}
.warningLabel {
display: block;
color: white;
font-size: large;
}
.warningDiv {
margin-left: auto;
margin-right: auto;
text-align: center;
}
...ext...
我做错了什么?
【问题讨论】:
-
尝试清除浏览器缓存,看看是否能解决您的问题。
-
@ConnorsFan 解决了我的问题!非常感谢!
-
按照你的建议,我添加了一个答案。