简体   繁体   中英

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>

its really strange to me ! here is the full code ... why not changed the background-color of the label_id = hour ??? where i made a mistake? please help ! i refreshed the code please test it on your own vs !

your code is working in here and in jsfiddle so the problem might be that you have another css rule that forcing span to not having a background color.

you can try to add !important at the end of the line of background-color to check if it is working at all .

good luck .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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