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

如果表单上的字段为空,单击按钮以指示错误时会触发css。但是,这仅在页面不在母版页内时才有效。当页面在母版页中并且单击按钮时,出现此错误:

http://img1.mukewang.com/60a9bbbd00012f0e13610516.jpg

这是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;

  }

}


浮云间
浏览 195回答 1
1回答

慕慕森

母版页应如下所示:<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs"&nbsp;&nbsp; &nbsp; Inherits="MasterPage" %><!DOCTYPE html><html><head runat="server">&nbsp; &nbsp; <title></title>&nbsp; &nbsp; <%--all meta tags--%>&nbsp; &nbsp; <%--all scripts put here will be available to every page that uses this master.--%>&nbsp; &nbsp; <asp:ContentPlaceHolder id="head" runat="server">&nbsp; &nbsp; &nbsp; &nbsp; <%--note this content placeholder in the head. don't put anything in it yet.&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; it will be available to pages that use this master.--%>&nbsp; &nbsp; </asp:ContentPlaceHolder></head><body>&nbsp; &nbsp; <form id="form1" runat="server">&nbsp; &nbsp; <div>&nbsp; &nbsp; &nbsp; &nbsp; <asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">&nbsp; &nbsp; &nbsp; &nbsp; </asp:ContentPlaceHolder>&nbsp; &nbsp; </div>&nbsp; &nbsp; </form>&nbsp; &nbsp; <%--add script tags and links-to-js before the closing body tag.&nbsp; &nbsp; &nbsp; &nbsp; they will be available to every page that uses this master page.--%></body></html>使用母版页的表单将如下所示:<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master"&nbsp;&nbsp; &nbsp; AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Default" %><asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">&nbsp; &nbsp; <%--this is the content placeholder from the head of the master.&nbsp; &nbsp; &nbsp; &nbsp; add styles and links-to-css for use on just this page.--%></asp:Content><asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">&nbsp; &nbsp; content for this page.&nbsp; &nbsp; <%--add scripts for just this page.--%></asp:Content>
打开App,查看更多内容
随时随地看视频慕课网APP