asp.net母版开发,很容易建立网页和界面。但是对于特殊要求的table、textbox、label之间的样式,如果
不想使用母版套用的css。可以采取在特定页面,单独定义内联样式的CSS。今天特意翻看了一下CSS
解释的优先顺序:
一般而言,所有的样式会根据下面的规则层叠于一个新的虚拟样式表中,其中数字 4 拥有最高的优先权。
- 浏览器缺省设置
- 外部样式表
- 内部样式表(位于 <head> 标签内部)
- 内联样式(在 HTML 元素内部)
<%@ Page Title="登录" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Login.aspx.cs" Inherits="WebApplication2.Account.Login" %>
<%@ Register Src="~/Account/OpenAuthProviders.ascx" TagPrefix="uc" TagName="OpenAuthProviders" %>
<asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent">
<span style="color:#ff6666;"> <style type="text/css">
#MainContent_Table1 { background-color: lightblue;margin:0px;
}
#MainContent_TextBox1 { margin:0px;
}
#MainContent_TextBox2 { margin:0px;
}
#MainContent_Table2 input { margin:0px;
font-size:1.2em;
font-family:Arial;
padding:1px;
}
</style></span>
<asp:Table ID="Table1" runat="server" >
<asp:TableRow>
<asp:TableCell>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</asp:TableCell>
<asp:TableCell>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell>
<asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>
</asp:TableCell>
<asp:TableCell>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
</asp:TableCell>
</asp:TableRow>
</asp:Table>
<asp:Table ID="Table2" runat="server">
<asp:TableRow>
<asp:TableCell>
<asp:Label ID="Label3" runat="server" Text="Label"></asp:Label>
</asp:TableCell>
<asp:TableCell>
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell>
<asp:Label ID="Label4" runat="server" Text="Label"></asp:Label>
</asp:TableCell>
<asp:TableCell>
<asp:TextBox ID="TextBox4" runat="server"></asp:TextBox>
</asp:TableCell>
</asp:TableRow>
</asp:Table>
</asp:Content>