CSS样式表没有显示效果

时间:2012-04-09 06:13:43

标签: c# asp.net css

我正在使用Asp.Net/C#。目前我正在登录页面上工作,我的login page不依赖于Master Page,因此指向我Stylesheet的链接设置在头部

<link  rel="stylesheet" href="Styles/Login.css" type="text/css"/>

问题是样式在登录页面上的控件上没有任何效果。这是我的css文件

body
{
    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
    font-size:75%; 
}
#loginbox
{
     position:fixed;
    background-color:#9cc3f7;
    border:2px solid #ddd;
    height:200px;
    width:300px;
    top:50%;
   margin-left: -130px;
   margin-top: -100px;
    left:50%;
}

这是登录页面

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="HomeLogin.aspx.cs" Inherits="CwizBankApp.HomeLogin" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">

    <title>Comwizard Systems | Login</title>
    <link  rel="stylesheet" href="Styles/Login.css" type="text/css"/>

</head>
<body>
    <form id="form1" runat="server">

    <div id="loginbox">
    <span>UserName:</span><asp:TextBox ID="txtUserName" runat="server"></asp:TextBox> <br /> 
    <span style="margin-left:6px;">Password:</span><asp:TextBox ID="txtPassword" runat="server" TextMode="Password"></asp:TextBox><br />  
    <asp:Button ID="cmdLogin"  runat="server" Text="Login" onclick="cmdLogin_Click" />

    </div>
    </form>
</body>
</html>

任何人都可以帮助我。 任何建议都非常感谢。 感谢

最后这个问题已经解决了 在web.config中添加它解决了它

<location path="~/Styles">
    <system.web>
        <authorization>
            <allow users="*" />
        </authorization>
    </system.web>
</location>

5 个答案:

答案 0 :(得分:2)

试试这个

   <location path="~/stylesheets">
        <system.web>
            <authorization>
                <allow users="*" />
            </authorization>
        </system.web>
   </location>

请使用样式表路径更新路径....请参阅此文

http://forums.asp.net/t/1678658.aspx/1

答案 1 :(得分:0)

快速提问,您能否检查一下css文件是否已经解决?

如果您使用的是chorme,则可以使用开发人员工具并使用网络部分查看所有要求的请求。

如果您使用的是firefox,请使用firebug。

由于

答案 2 :(得分:0)

查看源代码(通常按 CTRL + U ,如果使用chrome / firefox)并查找如果它显示href="Styles/Login.css",您应该可以将其作为指向样式表的链接。您应该确保首先正确地链接到它,它是否正确加载?

答案 3 :(得分:0)

尝试

href="@Url.Content("~/Styles/Login.css")"

而不是

href="Styles/Login.css"

如果您使用的是Visual Studio,智能感知(自动完成)将支持您找到确切的位置。打开Url.Content()方法的括号后,只需按Ctrl + Space。

答案 4 :(得分:0)

我检查了你的样品,没有任何问题。 Control“loginbox”确实获得了css风格。请检查您的css文件是否在正确的位置。

href="Styles/Login.css"
相关问题