[英]Css With Master Page C# ASP.NET
我正在嘗試將CSS添加到我的母版頁中,但是當我將其放入contentplaceholder標記中時卻無法正常工作。
有人可以解釋我為什么會發生嗎?
<head runat="server">
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>XXX</title>
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<asp:ContentPlaceHolder ID="head" runat="server">
<link rel="Stylesheet" href="styles/style.css" type="text/css" />
<link rel="Stylesheet" href="styles/bootstrap.min.css" type="text/css" />
<link rel="Stylesheet" href="styles/bootstrap-theme.min.css" type="text/css" />
<script type="text/javascript" src="javascript/jquery-1.11.3.min.js"></script>
<script type="text/javascript" src="javascript/bootstrap.min.js"></script>
</asp:ContentPlaceHolder>
</head>
當我那樣使用它不起作用我的style.css時,引導程序工作正常。 但是,當我將它(style.css)放到contentplaceholder之外時,它就可以正常工作。
為什么?
CSS文件
footer
{
background-color:Black;
}
步入身體
<footer>
<div class="row">
<div class="col-md-4">
<h5>
Mapa do Site</h5>
<ul>
<li><a href="">Home</a></li>
<li><a href="">Anuncie</a></li>
<li><a href="">Veículos Anunciados</a></li>
<li><a href="">Quem Somos</a></li>
<li><a href="">Contato</a></li>
</ul>
</div>
<div class="col-md-4">
</div>
<div class="col-md-4">
</div>
</div>
<div class="row">
<div class="col-md-12">
<p>
XXX 2015. Todos os direitos reservados.</p>
</div>
</div>
</footer>
這不是一個完美的解決方案,但請嘗試...
footer
{
background-color:Black !important;
}
我發現了我的錯誤。
當我將所有的css和js放入母版頁的contentplaceholder中時,它是從使用該母版頁的另一頁進行替換的被動方式。
比起我需要將它從contentplaceholder中刪除,並在開始時使用“ ../”更改文件的路徑。
現在看起來像這樣:
<head runat="server">
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>XXX</title>
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link rel="Stylesheet" href="styles/bootstrap.min.css" type="text/css" />
<link rel="Stylesheet" href="styles/bootstrap-theme.min.css" type="text/css" />
<link rel="Stylesheet" href="styles/style.css" type="text/css" />
<script type="text/javascript" src="../javascript/jquery-1.11.3.min.js"></script>
<script type="text/javascript" src="../javascript/bootstrap.min.js"></script>
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
</head>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.