向asp.net添加样式表(使用Visual Studio 2010)
发布时间:2020-12-16 07:19:13 所属栏目:asp.Net 来源:网络整理
导读:我正在尝试将样式表添加到asp.net Web表单中的母版页.基本上尝试为页面顶部创建内联导航菜单.我遇到了问题.我已经创建了样式表(如果这是一个html站点,我会创建相同的方式)并且我已将它放在您在下面看到的目录中.我不知道下面的代码如何显示样式表的任何关系.
我正在尝试将样式表添加到asp.net Web表单中的母版页.基本上尝试为页面顶部创建内联导航菜单.我遇到了问题.我已经创建了样式表(如果这是一个html站点,我会创建相同的方式)并且我已将它放在您在下面看到的目录中.我不知道下面的代码如何显示样式表的任何关系.
就像在HTML中一样,我会的 然后我的样式表看起来像这样…… ul { list-style-type:none; margin:0; padding:0; } li { display:inline; padding:20px; } CSS会让它显示为内联(顶部).但我不知道该去哪里. <%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %> <!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 runat="server"> <title>AR Toolbox</title> <asp:ContentPlaceHolder id="Stylesheets" runat="server"> <link rel="Stylesheet" href="/css/master.css" type="text/css" /> </asp:ContentPlaceHolder> <style type="text/css"> .style1 { width: 100%; } .style2 { height: 459px; } .style3 { width: 100%; height: 100%; } .style6 { height: 79px; } .style7 { width: 345px; height: 73px; } </style> </head> <body> <form id="form1" runat="server"> <table class="style1"> <tr> <td style="background-color: #A3A3A3; color: #FFFFFF; font-family: 'Arial Black'; font-size: large; font-weight: bold;" class="style6"> <asp:Menu ID="Menu1" runat="server"> <Items> <asp:MenuItem Text="Home" Value="Home"></asp:MenuItem> <asp:MenuItem Text="About" Value="About"></asp:MenuItem> <asp:MenuItem Text="Compliance" Value="Compliance"> <asp:MenuItem Text="Item 1" Value="Item 1"></asp:MenuItem> <asp:MenuItem Text="Item 2" Value="Item 2"></asp:MenuItem> </asp:MenuItem> <asp:MenuItem Text="Tools" Value="Tools"></asp:MenuItem> <asp:MenuItem Text="Contact" Value="Contact"></asp:MenuItem> </Items> </asp:Menu> </td> </tr> <tr> <td style="background-color: #A3A3A3; color: #FFFFFF; font-family: 'Arial Black'; font-size: large; font-weight: bold;" class="style6"> <img alt="South University'" class="style7" src="file:///C:/Users/jnewnam/Documents/Visual%20Studio%202010/WebSites/WebSite1/img/suo_n_seal_hor_pantone.png" /></td> </tr> <tr> <td class="style2"> <table class="style3"> <tr> <td> </td> </tr> </table> </td> </tr> <tr> <td style="color: #FFFFFF; background-color: #A3A3A3"> This is the footer.</td> </tr> </table> </form> </body> </html> 解决方法
这里有几件事.
首先,你在3个地方定义你的CSS! 在头部和外部.我建议你只选一个.我打算在外面提出建议. 我建议你在ASP表格中更新你的代码 <td style="background-color: #A3A3A3; color: #FFFFFF; font-family: 'Arial Black'; font-size: large; font-weight: bold;" class="style6"> 对此: <td class="style6"> 然后更新你的CSS .style6 { height: 79px; background-color: #A3A3A3; color: #FFFFFF; font-family: 'Arial Black'; font-size: large; font-weight: bold; } 这将删除内联. 现在,将它从webForm的头部移开. <%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %> <!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 runat="server"> <title>AR Toolbox</title> <link rel="Stylesheet" href="css/master.css" type="text/css" /> </head> <body> <form id="form1" runat="server"> <table class="style1"> <tr> <td class="style6"> <asp:Menu ID="Menu1" runat="server"> <Items> <asp:MenuItem Text="Home" Value="Home"></asp:MenuItem> <asp:MenuItem Text="About" Value="About"></asp:MenuItem> <asp:MenuItem Text="Compliance" Value="Compliance"> <asp:MenuItem Text="Item 1" Value="Item 1"></asp:MenuItem> <asp:MenuItem Text="Item 2" Value="Item 2"></asp:MenuItem> </asp:MenuItem> <asp:MenuItem Text="Tools" Value="Tools"></asp:MenuItem> <asp:MenuItem Text="Contact" Value="Contact"></asp:MenuItem> </Items> </asp:Menu> </td> </tr> <tr> <td class="style6"> <img alt="South University'" class="style7" src="file:///C:/Users/jnewnam/Documents/Visual%20Studio%202010/WebSites/WebSite1/img/suo_n_seal_hor_pantone.png" /></td> </tr> <tr> <td class="style2"> <table class="style3"> <tr> <td> </td> </tr> </table> </td> </tr> <tr> <td style="color: #FFFFFF; background-color: #A3A3A3"> This is the footer.</td> </tr> </table> </form> </body> </html> 现在,在一个名为master.css的新文件中(在你的css文件夹中)添加 ul { list-style-type:none; margin:0; padding:0; } li { display:inline; padding:20px; } .style1 { width: 100%; } .style2 { height: 459px; } .style3 { width: 100%; height: 100%; } .style6 { height: 79px; background-color: #A3A3A3; color: #FFFFFF; font-family: 'Arial Black'; font-size: large; font-weight: bold; } .style7 { width: 345px; height: 73px; } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net – 实体框架 – 映射不映射存储过程?
- asp.net – 脚本标记和“<%...%>”标记之间有什么区别?
- 使用Openiddict的ASP.NET Core 1.0 OAuth服务器
- asp.net-mvc – 实体框架 – 选择特定列并返回强类型而不丢
- asp.net-mvc-3 – 可以用“@:@”修复的MVC4剃刀的可能的突
- asp.net – 为什么设置为SqlServer时会话超时不起作用?
- asp.net – 如何查询具有多个根和过滤的嵌套集模型
- asp.net – System.DirectoryServices – 服务器不可操作
- asp.net – “viewstate MAC的验证失败.如果这个应用程序由
- asp.net-mvc – 如何本地化枚举并使用类似于Html.SelectLis
推荐文章
站长推荐
热点阅读