Building Beautiful, Responsive Sites with Bootstrap =================================================== By `Steve Smith`_ Bootstrap is currently the most popular web framework for developing responsive web applications. It offers a number of features and benefits that can improve your users' experience with your web site, whether you're a novice at front-end design and development or an expert. Bootstrap is deployed as a set of CSS and JavaScript files, and is designed to help your website or application scale efficiently from phones to tablets to desktops. In this article: - `Getting Started`_ - `Basic Templates and Features`_ - `More Themes`_ - `Components`_ - `JavaScript Support`_ Getting Started --------------- There are several ways to get started with Bootstrap. If you're starting a new web application in Visual Studio, you can choose the default starter template for ASP.NET 5, in which case Bootstrap will come pre-installed: .. image:: bootstrap/_static/bootstrap-in-starter-template.png Adding Bootstrap to an ASP.NET 5 project is simply a matter of adding it to ``bower.json`` as a dependency: .. code-block:: javascript :emphasize-lines: 5 { "name": "ASP.NET", "private": true, "dependencies": { "bootstrap": "3.0.0", "jquery": "1.10.2", "jquery-validation": "1.11.1", "jquery-validation-unobtrusive": "3.2.2", "hammer.js": "2.0.4", "bootstrap-touch-carousel": "0.8.0" } } This is the recommended way to add Bootstrap to an ASP.NET 5 project. You can also install bootstrap using one of several package managers, such as bower, npm, or NuGet. In each case, the process is essentially the same: Bower ^^^^^ .. code-block:: console bower install bootstrap npm ^^^ .. code-block:: console npm install bootstrap NuGet ^^^^^ .. code-block:: console Install-Package bootstrap .. note:: The recommended way to install client-side dependencies like Bootstrap in ASP.NET 5 is via Bower (using ``bower.json``, as shown above). The use of npm/NuGet are shown to demonstrate how easily Bootstrap can be added to other kinds of web applications, including earlier versions of ASP.NET. If you're referencing your own local versions of Bootstrap, you'll need to reference them in any pages that will use it. In the default ASP.NET site template, the ``_Layout.cshtml`` file does so like this: .. literalinclude:: bootstrap/sample/_Layout.cshtml :language: html :linenos: :emphasize-lines: 10,55 You can also simply reference Bootstrap using its CDN (Content Delivery Network) links, which is how you may wish to have your application reference bootstrap in production in any case. Simply replace the two references above with these: .. code-block:: html Note that if you're going to be using any of Bootstrap's jQuery plugins, you will also need to reference jQuery (as shown above on line 40). If you're going the CDN route, you can of course use jQuery's CDN as well: .. code-block:: html Basic Templates and Features ---------------------------- The most basic Bootstrap template looks very much like the _Layout.cshtml file shown above, and simply includes a basic menu for navigation and a place to render the rest of the page. Basic Navigation ^^^^^^^^^^^^^^^^ The default template uses a set of ``
`` elements to render a top navbar and the main body of the page. If you're using HTML5, you can replace the first ``
`` tag with a ``