asp.net母版样式屏蔽

asp.net母版开发,很容易建立网页和界面。但是对于特殊要求的table、textbox、label之间的样式,如果

不想使用母版套用的css。可以采取在特定页面,单独定义内联样式的CSS。今天特意翻看了一下CSS

解释的优先顺序:

一般而言,所有的样式会根据下面的规则层叠于一个新的虚拟样式表中,其中数字 4 拥有最高的优先权。

  1. 浏览器缺省设置
  2. 外部样式表
  3. 内部样式表(位于 <head> 标签内部)
  4. 内联样式(在 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>


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值