应该注意的是,您也可以有多个母版页。 Visual Studio 还允许您创建页面并选择母版页,这是添加项目时的其他选项之一。
I would highly recommend using a master page. It gives you the ability to have one consistent look across all your pages. Also if you decide to change the layout your only changing one file!
Simply reference the CSS file in your master page and it will be applied to every page the master page is used on. Something like <link href="~/styles/Style.css" rel="stylesheet" type="text/css" />
It should be noted that you can also have more then one master page. Visual studio also allows you to create pages and select the master page, it's one of the other options when adding an item.
You should have a master page if many or all of your pages share a common User Interface (such as a header, footer, navigation bar, etc).
It really doesn't matter where you put the link to the CSS file, because the CSS will be applied to the whole page either way. If the CSS is common to the entire website (or all the ones that share the same master page) put it in the Master Page. If the CSS file is page specific and you can't put it in the Master page because it conflicts with another page specific, put it in the page (in the head ContentSection).
I would suggest using master pages to control the general layout of your site, so you don't have to repeat the layout on every page. You don't need to do anything special in the CSS file to account for the master page, but you should add the link to the CSS file in the header of the master page, so it carries through to all of the pages using the master page.
发布评论
评论(3)
我强烈建议使用母版页。它使您能够在所有页面上保持一致的外观。另外,如果您决定更改布局,则只需更改一个文件!
只需在母版页中引用 CSS 文件,它将应用于使用母版页的每个页面。类似于
应该注意的是,您也可以有多个母版页。 Visual Studio 还允许您创建页面并选择母版页,这是添加项目时的其他选项之一。
I would highly recommend using a master page. It gives you the ability to have one consistent look across all your pages. Also if you decide to change the layout your only changing one file!
Simply reference the CSS file in your master page and it will be applied to every page the master page is used on. Something like
<link href="~/styles/Style.css" rel="stylesheet" type="text/css" />
It should be noted that you can also have more then one master page. Visual studio also allows you to create pages and select the master page, it's one of the other options when adding an item.
如果您的许多或所有页面共享一个通用的用户界面(例如页眉、页脚、导航栏等),您应该拥有一个母版页。
将 CSS 文件的链接放在哪里并不重要,因为无论哪种方式 CSS 都会应用到整个页面。如果 CSS 对于整个网站(或共享同一母版页的所有网站)是通用的,请将其放在母版页中。如果 CSS 文件是特定于页面的,并且您不能将其放入母版页中,因为它与其他特定于页面的冲突,请将其放入页面中(在 ContentSection 的头部)。
You should have a master page if many or all of your pages share a common User Interface (such as a header, footer, navigation bar, etc).
It really doesn't matter where you put the link to the CSS file, because the CSS will be applied to the whole page either way. If the CSS is common to the entire website (or all the ones that share the same master page) put it in the Master Page. If the CSS file is page specific and you can't put it in the Master page because it conflicts with another page specific, put it in the page (in the head ContentSection).
我建议使用母版页来控制网站的总体布局,这样您就不必在每个页面上重复布局。您不需要在 CSS 文件中执行任何特殊操作来说明母版页,但您应该在母版页的标题中添加指向 CSS 文件的链接,以便它可以传递到使用母版页的所有页面页。
母版页标题:
I would suggest using master pages to control the general layout of your site, so you don't have to repeat the layout on every page. You don't need to do anything special in the CSS file to account for the master page, but you should add the link to the CSS file in the header of the master page, so it carries through to all of the pages using the master page.
Master page header: