繁体   English   中英

标签背景颜色不起作用

[英]label background-color not working

<%@ Master Language="C#" %>
<%@ Import Namespace="System.Globalization" %>

<!DOCTYPE html>

<script runat="server">
    void page_load()
    {
        PersianCalendar pc = new PersianCalendar();
        day.Text = pc.GetDayOfWeek(DateTime.Now).ToString();
        hour.Text = string.Format("{0} : {1} : {2}", DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second);
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <style type="text/css">
        body{
            background-color:#FFFACD;
        }
        #Main{
            margin:5px;
        }
        #Title{
            background-color:#F0FFFF;
            height:50px;
            position:relative;
            top: 0px;
            left: 0px;
        }
        #Title span{
            background-color:#FDF5E6;
            text-align:center;
            font-family:"Sakkal Majalla";
            font-size:larger;
            margin-top:7px;
            border:solid 1px #DEB887;
            display:block;
            width:60px;
            height:35px;
            float:left;
        }
         #hour{
            background-color:red;
        }
    </style>
    <title></title>
    <asp:ContentPlaceHolder id="head" runat="server">
    </asp:ContentPlaceHolder>
</head>
<body>
    <form id="form1" runat="server">
        <div id="Main">
            <div id="Title">
                <span style="float:right;margin-right:10px;">به نام خداوند جان و خرد</span>
                <span style="margin-left:5px"><asp:Label runat="server" ID="hour">aaa</asp:Label></span>
                <span style=" ">ساعت</span>
                <span style=" "><asp:Label runat="server" ID="day" BorderWidth="0px" Font-Names="Sakkal Majalla" Font-Size="Large" BackColor="#3366FF" Height="15px"></asp:Label></span>
                <span style=" ">امروز</span>
            </div>
        </div>
    </form>
</body>
</html>

对我来说真的很奇怪! 这是完整的代码...为什么不更改label_id = hour的背景颜色? 我在哪里弄错了? 请帮忙 ! 我刷新了代码,请自行测试!

您的代码在这里和jsfiddle中都可以正常工作,所以问题可能出在您有另一个css规则,强制跨度不具有背景色。

您可以尝试在background-color行的末尾添加!important,以检查其是否正常运行。

祝好运 。

暂无
暂无

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

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