[英]Unable to apply CSS style to an asp label
当我想将我的一种CSS样式应用于asp标签时,我得到了一个奇怪的结果。 样式实际上仅具有部分作用,例如, background-color
和颜色之类的属性生效,而宽度和高度的属性则无效。 我不明白为什么。
均价
<div id="wrap">
<div id="left" class="Tablestyle">
<asp:Label ID="Label1" runat="server" Text="Entry Number: " class="Tablestyle"></asp:Label>
<br /><div class="separator"> </div>
<asp:Label ID="Label3" runat="server" Text="ID Number: " class="Tablestyle"></asp:Label>
<br /><div class="separator"> </div>
<asp:Label ID="Label2" runat="server" Text="Type: " class="Tablestyle"></asp:Label>
</div>
<div id="Mid"> </div>
<div id="right">
<asp:Label ID="IdBox" runat="server" class="TableStyleInfo"></asp:Label>
<br /><div class="separator"> </div>
<asp:Label ID="IdNumBox" runat="server" class="TableStyleInfo"></asp:Label>
<br /><div class="separator"> </div>
<asp:Label ID="TypeBox" runat="server" class="TableStyleInfo"></asp:Label>
</div>
</div>
CSS
#wrap
{
width:555px;
margin:auto;
text-align:center;
}
#Mid
{
width:5px;
height:330px;
float:left;
background-color:White;
}
#right
{
width:400px;
float:left;
text-align:left;
background-color:Yellow;
}
#left
{
width:150px;
float:left;
text-align:right;
background-color:Green;
}
.separator
{
height:4px;
line-height:4px;
background-color:White;
}
.Tablestyle
{
width:150px;
height:20px;
text-align:right;
color:white;
font-weight:bold;
background-color:#507CD1;
}
.TableStyleInfo
{
width:400px;
height:20px;
text-align:left;
color:Black;
background-color:#EFF3FB;
}
我也尝试将class
更改为CssClass
但没有发生任何变化。
如果有人可以指出我的错误或提示我为什么不能应用width和height属性,我将不胜感激。
<asp:Label>
转换为html <span>
元素,该元素是一个内联元素,没有宽度或高度。 您可以通过将其更改为CSS中的块级元素来实施此操作:
.Tablestyle {
display: block; // add this
width: 150px;
height: 20px;
text-align: right;
color: white;
font-weight: bold;
background-color: #507CD1;
}
.TableStyleInfo {
display: block; // add this
width: 400px;
height: 20px;
text-align: left;
color: Black;
background-color: #EFF3FB;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.