[英]css not working in certain section of master page but working in separate web form asp.net
I have created a master page with a basic login page and applied css in it. 我创建了一个具有基本登录页面的母版页面,并在其中应用了CSS。 But i get styles only for background and footer only, other divs does not get applied. 但是我只为背景和页脚设置样式,其他div没有应用。
so i decided to create a web form and copied it without contentplaceholder it works 所以我决定创建一个Web表单,并在没有contentplaceholder的情况下将其复制了
My css code: http://pastebin.com/raw.php?i=0N6SzL5p 我的CSS代码: http : //pastebin.com/raw.php? i = 0N6SzL5p
My css working Web form code: http://pastebin.com/raw.php?i=QrvttGqN 我的CSS工作的Web表单代码: http : //pastebin.com/raw.php?i=QrvttGqN
Master page code: http://pastebin.com/raw.php?i=C2LH0SrE 母版页代码: http : //pastebin.com/raw.php?i = C2LH0SrE
And its content login page: http://pastebin.com/raw.php?i=GdQpWnVX 及其内容登录页面: http : //pastebin.com/raw.php?i=GdQpWnVX
I'm a newbie in asp and i'm not trolling. 我是ASP的新手,但我没有拖钓。 If it is a silly mistake please point it out and help me 如果这是一个愚蠢的错误,请指出并帮助我
Based on your stylesheet, the problem with the master page was that you should have a wrapper <div>
that surrounds all of your nested elements. 根据您的样式表,母版页的问题在于您应该具有一个包装器<div>
,该包装器包围所有嵌套元素。
A lot of your <div id="xx">
elements should be changed to <div class="xx">
as your stylesheet is CSS class definitions. 由于样式表是CSS类定义,因此许多<div id="xx">
元素应更改为<div class="xx">
。 eg 例如
From: 从:
<div id="top" runat="server">
and.. 和..
<div id="mainpage" runat="server">
and.. 和..
To: 至:
<div class="top">
and.. 和..
<div class="mainpage">
and.. 和..
<div class="footer">
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Demo.master.cs" Inherits="UI.Master.Demo" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<link href="../CSS/Site.css" rel="stylesheet" />
<link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css" />
<script src="//code.jquery.com/jquery-1.9.1.js"></script>
<script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
<title>Demo</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<div class="top">
<div class="topmiddle">
<div class="logreg" id="login_reg" runat="server">
<a href="~/My_Account/Demo_login.aspx" class="toptext" runat="server">Login</a>
<a href="~/My_Account/Demo_Register.aspx" class="toptext" runat="server">Register</a>
</div>
<div class="userlog" id="user_logout" runat="server" visible="false">
Welcome<asp:Label ID="username" runat="server">!</asp:Label>
<a id="A3" href="Logout.aspx" class="atypesty" runat="server">LogOUT</a>
</div>
</div>
</div>
<div class="mainpage">
<table class="maintable">
<tr>
<td>
<img src="../Images/logo.jpg" class="logo" />
</td>
<td class="menucenter">
<ul id="Nav">
<li>
<a href="#">Home</a>
</li>
<li id="Navprofile" runat="server">
<asp:LinkButton ID="lnbtn_Profile" runat="server"></asp:LinkButton>
</li>
<li>
<a href="#">About Us</a>
</li>
<li>
<a href="#">Contact Us</a>
</li>
</ul>
</td>
</tr>
</table>
<asp:ContentPlaceHolder ID="demo" runat="server"></asp:ContentPlaceHolder>
</div>
<div class="footer">
<p>All words, images and code copyright ©2014 demo.com. All rights reserved.</p>
</div>
</div>
</form>
</body>
</html>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.