0

まず、login.aspx ページのコード:

<%@ Page Title="Log In" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
CodeBehind="Login.aspx.cs" Inherits="DoubleEntryForm.Account.Login" %>

<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<h2>
    &nbsp;Log In
</h2>
<%--<p>
    Please enter your username and password.
    <asp:HyperLink ID="RegisterHyperLink" runat="server" EnableViewState="false">Register</asp:HyperLink> if you don't have an account.
</p>--%>
<asp:Login ID="LoginUser" runat="server" EnableViewState="false" RenderOuterTable="false" DestinationPageUrl="~/Destruction Form.aspx">
    <LayoutTemplate>
        <span class="failureNotification">
            <asp:Literal ID="FailureText" runat="server"></asp:Literal>
        </span>
        <asp:ValidationSummary ID="LoginUserValidationSummary" runat="server" CssClass="failureNotification" 
             ValidationGroup="LoginUserValidationGroup"/>
        <div class="accountInfo">
            <fieldset class="login">
                <legend>Account Information</legend>
                <p>
                    <asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName">Username:</asp:Label>
                    <asp:TextBox ID="UserName" runat="server" CssClass="textEntry"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="UserNameRequired" runat="server" ControlToValidate="UserName" 
                         CssClass="failureNotification" ErrorMessage="User Name is required." ToolTip="User Name is required." 
                         ValidationGroup="LoginUserValidationGroup">*</asp:RequiredFieldValidator>
                </p>
                <p>
                    <asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Password">Password:</asp:Label>
                    <asp:TextBox ID="Password" runat="server" CssClass="passwordEntry" TextMode="Password"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="PasswordRequired" runat="server" ControlToValidate="Password" 
                         CssClass="failureNotification" ErrorMessage="Password is required." ToolTip="Password is required." 
                         ValidationGroup="LoginUserValidationGroup">*</asp:RequiredFieldValidator>
                </p>
                <p>
                    <asp:CheckBox ID="RememberMe" runat="server"/>
                    <asp:Label ID="RememberMeLabel" runat="server" AssociatedControlID="RememberMe" CssClass="inline">Keep me logged in</asp:Label>
                </p>
            </fieldset>
            <p class="submitButton">
                <asp:Button ID="LoginButton" runat="server" CommandName="Login" Text="Log In" ValidationGroup="LoginUserValidationGroup"/>
            </p>
        </div>
    </LayoutTemplate>
</asp:Login>

このページでは、CSS スタイルを追加しようとしていますが、どの方法もうまくいきません。そのスタイリングは次のとおりです。

<style type="text/css">

body{
    margin:0;
    padding:0;
    background-color:#eae9e9;}

#scan-table-wrapper {
    width: 968px;
    margin: 0 auto 0 auto;
    background-image: url("Images/wrapper-bg.png");}    

#scan-table-body{
    margin:0 30px 0 30px;
    padding-top:30px;}

.auto-style1 {
    width: 880px;
    height: 100px;}

</style>

また、タイトル画像も追加しようとしています。ただし、コードを HeaderContent セクションに配置すると、タイトル画像を表示しようとして失敗したように見え、背景がまったく表示されません (失敗すると、空のボックスに小さな赤い X が表示されます)初期化)。MainContent に配置すると、div にスタイルを配置できないと記載されています。ただし、divに入れるのではなく、MainContentが始まるすぐ下の行に入れています。

CSS を扱うのはこれが初めてなので、少し慣れていません。ページに正しく表示されるようにするには、これらをどこに配置すればよいですか?

4

1 に答える 1

2

実際、タグは HeadContent 、 content に入ります。赤い十字の画像が表示されている場合、css は正常に機能していますが、言及したディレクトリで画像が見つからないことを意味します。../1 つ上のディレクトリを意味する適切なパスを親切に設定してください。

たとえば、プロジェクト構造がこれである場合

Root -> Images/wrapper-bg.png
     -> Pages/Your Aspx pages

aspxページにスタイルがあり、使用する必要があります

background-image: url('../Images/wrapper-bg.png');} // 一重引用符を使用

../ は、ページ ディレクトリの外に移動し、ルート内に配置します。上記の場合は、Images/Wrapper-bg.png とパスが満たされます。それで全部です。

ボディバック用

css をマスター ページの Head セクションに移動します。body が外部 css またはインライン css から適用される css がこれ以上存在しないことを確認してください。

CSS を扱う良い方法

プロジェクト名に style.css などのスタイルシートを追加します。css ファイルをマスター ページのヘッド セクションにドラッグ ドロップすると、その参照が自動的に追加されます。次に、そのファイルに css を書き始めます。すべての子ページは、指示に基づいてそのファイルからスタイルを自動的に継承します。また、サードパーティの CSS エディターを使用して、css を簡単に作成し、学習することもできます。私は通常、Rapid CSSを使用します。

試してみる必要があります

私の非常に好ましいモードは、Jetbrains Resharper を使用した .Net 自体です。かっこいい!!

于 2013-10-03T15:28:29.520 に答える