[英]CSS Stylesheet not showing effects
我正在使用Asp.Net/C#
。目前我正在登錄頁面上工作,我的login page
不依賴於Master Page
,因此我在標題部分設置了指向Stylesheet
的鏈接
<link rel="stylesheet" href="Styles/Login.css" type="text/css"/>
問題是 styles 對登錄頁面上的控件沒有任何影響。這是我的 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>
試試這個
<location path="~/stylesheets">
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</location>
請用您的樣式表路徑更新路徑....請參閱本文
快速提問,你能檢查一下 css 文件是否真的被解析了嗎?
如果您使用的是 chorme,則可以使用開發人員工具並使用 .network 部分查看 go 通過的所有請求。
如果您使用的是 firefox,請使用螢火蟲。
謝謝
查看源代碼(如果使用 chrome/firefox,通常按CTRL + U )並找到href="Styles/Login.css"
的位置,您應該可以單擊它作為樣式表的鏈接。 您應該首先確保您實際上正確地鏈接到它,它是否正確加載?
嘗試
href="@Url.Content("~/Styles/Login.css")"
代替
href="Styles/Login.css"
如果您使用的是 Visual Studio,智能感知(自動完成)將支持您找到准確的位置。 打開 Url.Content() 方法的括號后,只需按 Ctrl+Space。
我檢查了你的樣品,完全沒有問題。 控件“登錄框”確實獲得了 css 樣式。 請檢查您的 css 文件是否在正確的位置。
href="Styles/Login.css"
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.