twitter-bootstrap 如何轻松地将 Bootstrap 应用于已完成的 ASP.net MVC 4 应用程序?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20998989/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to easily apply Bootstrap to a completed ASP.net MVC 4 application?
提问by Tassisto
I created an ASP.net MVC 4 app. Now I decided to integrate bootstrap 3.0.3 in my app. But I found out it's not easy. I searched on google and found tutorials where they explain how to integrate bootstrap with a totally new ASP.net MVC app.
我创建了一个 ASP.net MVC 4 应用程序。现在我决定在我的应用程序中集成 bootstrap 3.0.3。但我发现这并不容易。我在谷歌上搜索并找到了教程,其中解释了如何将引导程序与全新的 ASP.net MVC 应用程序集成。
My ASP.net MVC 4 app has 'Razor' as View engine and I selected the 'Internet Application' template.
我的 ASP.net MVC 4 应用程序使用“Razor”作为视图引擎,我选择了“Internet 应用程序”模板。
Do I have to modify all the views step-by-step because I didn't chose Bootstrap at the beginning?
是不是因为一开始没有选择Bootstrap,所以要一步步修改所有的views?
If I only include the bootstrap.css and bootstrap.js the pages become deformed.
如果我只包含 bootstrap.css 和 bootstrap.js,页面就会变形。
采纳答案by Matthew Verstraete
You do not have to delete the Site.css file since it contains the currently defined styling for your site, if you remove it you remove your styling. If you want to include the bootstrap.css call it BEFORE your site.css file. The reason your site is deformed when you just use the bootstrap css file is because you did not design for bootstrap but your own custom Site.CSS. bootstrap can be easy or extremely hard to integrate depending on the complexity of your site. Even if you call the bootstrap css before your site css it can, and more likely will, affect how your site looks. You will just have to add it, look at the site, and the go make the needed changes to fix any issues.
您不必删除 Site.css 文件,因为它包含当前为您的站点定义的样式,如果您删除它,您将删除您的样式。如果您想包含 bootstrap.css,请在您的 site.css 文件之前调用它。当您只使用 bootstrap css 文件时,您的站点变形的原因是因为您不是为 bootstrap 设计的,而是您自己的自定义 Site.CSS。根据您网站的复杂程度,bootstrap 可以很容易或极难集成。即使您在网站 css 之前调用 bootstrap css,它也可能,而且更有可能会影响您网站的外观。您只需添加它,查看站点,然后进行所需的更改以解决任何问题。

