为了账号安全,请及时绑定邮箱和手机立即绑定

将页面加载到母版页中时,css不触发,但是当页面未嵌套到母版页时,css不会触发

将页面加载到母版页中时,css不触发,但是当页面未嵌套到母版页时,css不会触发

C#
浮云间 2021-05-18 17:14:12
如果表单上的字段为空,单击按钮以指示错误时会触发css。但是,这仅在页面不在母版页内时才有效。当页面在母版页中并且单击按钮时,出现此错误:这是css上的代码:    [ Alert validate ]*/.validate-input {  position: relative;}.alert-validate::before {  content: attr(data-validate);  position: absolute;  max-width: 70%;  background-color: #fff;  border: 1px solid #c80000;  border-radius: 3px;  padding: 4px 25px 5px 10px;  top: 50%;  -webkit-transform: translateY(-50%);  -moz-transform: translateY(-50%);  -ms-transform: translateY(-50%);  -o-transform: translateY(-50%);  transform: translateY(-50%);  right: 12px;  pointer-events: none;  font-family: Ubuntu-Regular;  color: #c80000;  font-size: 14px;  line-height: 1.4;  text-align: left;  visibility: hidden;  opacity: 0;  -webkit-transition: opacity 0.4s;  -o-transition: opacity 0.4s;  -moz-transition: opacity 0.4s;  transition: opacity 0.4s;}.alert-validate::after {  content: "\f12a";  font-family: FontAwesome;  display: block;  position: absolute;  color: #c80000;  font-size: 18px;  top: 50%;  -webkit-transform: translateY(-50%);  -moz-transform: translateY(-50%);  -ms-transform: translateY(-50%);  -o-transform: translateY(-50%);  transform: translateY(-50%);  right: 18px;}.alert-validate:hover:before {  visibility: visible;  opacity: 1;}@media (max-width: 992px) {  .alert-validate::before {    visibility: visible;    opacity: 1;  }}
查看完整描述

1 回答

?
慕慕森

TA贡献1856条经验 获得超17个赞

母版页应如下所示:


<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" 

    Inherits="MasterPage" %>


<!DOCTYPE html>


<html>

<head runat="server">

    <title></title>

    <%--all meta tags--%>

    <%--all scripts put here will be available to every page that uses this master.--%>


    <asp:ContentPlaceHolder id="head" runat="server">

        <%--note this content placeholder in the head. don't put anything in it yet.

            it will be available to pages that use this master.--%>

    </asp:ContentPlaceHolder>

</head>

<body>


    <form id="form1" runat="server">

    <div>

        <asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">


        </asp:ContentPlaceHolder>

    </div>

    </form>


    <%--add script tags and links-to-js before the closing body tag.

        they will be available to every page that uses this master page.--%>


</body>

</html>

使用母版页的表单将如下所示:


<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" 

    AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Default" %>


<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">

    <%--this is the content placeholder from the head of the master.

        add styles and links-to-css for use on just this page.--%>

</asp:Content>


<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">


    content for this page.


    <%--add scripts for just this page.--%>

</asp:Content>


查看完整回答
反对 回复 2021-05-23
  • 1 回答
  • 0 关注
  • 177 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信