ASP.Net,母版页:每页样式表 [英] ASP.Net, Master Pages : style-sheet per page
问题描述
这些都是我的假设,这些正确的?
Those are my assumptions, are these correct?
- 使用CSS布局是preferred过
使用表。 - 的CSS ishould在一个单独的文件中提取的,而不是在衬里。
- CSS是进口的(挂)从位于Site.master母,因此所有的CSS是进口的(并且适用于)所有的.aspx页面。
鉴于此,我有一个母版页的一个项目,和两个.aspx页。相应的网页有ID为记录表。
Given that, I have a project with one master page, and two .aspx pages. Each of those pages has a table with id "records".
问:我可以导入.css文件为每个.aspx页面中
Question: Can I import a .css file for each individual .aspx page?
有没有更好的办法的范围的单页中的HTML元素?
Is there a better way to scope html elements within single page?
推荐答案
CSS是preferred过的一切表,除了实际presenting一个表(如表格数据,如为preadsheet或网格) 。虽然有一些怪异的情况下,表是完成一些影响跨浏览器的唯一途径。主要是 - 总是用CSS除非你不能。然后使用表:)
CSS is preferred over tables for everything except actually presenting A Table (e.g. tabular data, like a spreadsheet or a grid). Although there are a few weird cases where tables are the only way to accomplish some effects cross-browser. Mainly - always use CSS except when you can't. Then use tables :)
要你的第一个问题 - 你当然可以包括个人网页上的CSS文件。你甚至可以使用占位符做到这一点:
To your first question - of course you can include CSS files on the individual page. You can even do it using placeholders:
.master:
<head>
<link rel="stylesheet" type="text/css" href="global.css" />
<asp:ContentPlaceHolder runat="server" id="stylesheet" />
</head>
.aspx:
<asp:Content runat="server" ContentPlaceHolderID="stylesheet">
<link rel="stylesheet" type="text/css" href="page_specific.css" />
</asp:Content>
要范围样式的页面的水平,我经常把一个类上的&LT;身体GT;
标签:
To scope styles to the page level, I often put a class on the <body>
tag:
<body class="contact-page">
然后在CSS我可以定位应该是页面上的不同具体项目:
Then in CSS I can target specific items that should be different on that page:
.contact-page .something h3 .more {style}
这篇关于ASP.Net,母版页:每页样式表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!