mdbootstrap4-pro
Version:
MDBootstrap 4 PRO
145 lines (97 loc) • 10.7 kB
HTML
<!--Section: Tutorial content-->
<section>
<div class="text-center mb-4">
<p>In this lesson, you will learn how to create a basic construction of your project and set up a grid layout.</p>
<a class="btn btn-primary" href="" role="button">Final result preview <i class="fa fa-eye ml-1"></i></a>
</div>
<p class="h5 mt-4">Step 1</p>
<p> Open index.html file in your project folder (the folder where you have unzipped MDB package).</p>
<p class="h5 mt-4">Step 2</p>
<p> Let's create a basic structure of our project. We'll divide the page into the 3 sections:</p>
<p><code><header></code> - for navigation</p>
<p><code><main></code> - for website content</p>
<p><code><footer></code> - for additional information and links</p>
<p class="mt-4"><strong>Paste following code below <code><body></code> tag:</strong></p>
<pre class="code-toolbar"><code class="language-markup">
<!--Main Navigation--> <header> </header> <!--Main Navigation--> <!--Main layout--> <main> </main> <!--Main layout--> <!--Footer--> <footer> </footer> <!--Footer-->
</code></pre>
<p class="h5 mt-4">Step 3</p>
<p>We will create <strong>navigation bar </strong>first. From the MDB documentation (menu on the left, components ->
<a href="https://mdbootstrap.com/components/navbar/#basic-example">navbars</a> ) grab a Basic Navbar and paste it
between <code><header></code> tags:</p>
<pre class="code-toolbar"><code class="language-markup">
<nav class="navbar navbar-expand-lg navbar-dark indigo"> <a class="navbar-brand" href="#">Navbar</a> <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation"> <span class="navbar-toggler-icon"></span> </button> <div class="collapse navbar-collapse" id="navbarSupportedContent"> <ul class="navbar-nav mr-auto"> <li class="nav-item active"> <a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a> </li> <li class="nav-item"> <a class="nav-link" href="#">Features</a> </li> <li class="nav-item"> <a class="nav-link" href="#">Pricing</a> </li> <li class="nav-item dropdown"> <a class="nav-link dropdown-toggle" id="navbarDropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Dropdown </a> <div class="dropdown-menu dropdown-primary" aria-labelledby="navbarDropdownMenuLink"> <a class="dropdown-item" href="#">Action</a> <a class="dropdown-item" href="#">Another action</a> <a class="dropdown-item" href="#">Something else here</a> </div> </li> </ul> <form class="form-inline"> <input class="form-control mr-sm-2" type="text" placeholder="Search" aria-label="Search"> </form> </div> </nav>
</code></pre>
<p>Save the file and open it in the browser. You will see a blue navigation bar on the top of the page.</p>
<p>That was easy, wasn't it? Of course, our navigation requires a few modifications, but we'll take care of it later.</p>
<p>If you want you can play a little with Navbar. Try to modify links names and set up redirections to some already existing
in the Internet websites.</p>
<p>Now let's try something more exciting. Let's add a content to our website.</p>
<p class="h5 mt-4">Step 4</p>
<p>Before we do that, first we have to structure our project. We'll use a <strong>Bootstrap grid</strong> for that.</p>
<p><strong>Paste the following code between <code><main></code> tags:</strong></p>
<pre class="code-toolbar"><code class="language-markup">
<!--Main container--> <div class="container"> <!--Grid row--> <div class="row"> <!--Grid column--> <div class="col-md-7"> </div> <!--Grid column--> <!--Grid column--> <div class="col-md-5"> </div> <!--Grid column--> </div> <!--Grid row--> <!--Grid row--> <div class="row"> <!--Grid column--> <div class="col-lg-4 col-md-12"> </div> <!--Grid column--> <!--Grid column--> <div class="col-lg-4 col-md-6"> </div> <!--Grid column--> <!--Grid column--> <div class="col-lg-4 col-md-6"> </div> <!--Grid column--> </div> <!--Grid row--> </div> <!--Main container-->
</code></pre>
<p>Now let's have a look at elements we've used above. </p>
<p>All of them are parts of <strong>Bootstrap Grid System</strong>, which let us create responsive websites adjusted to
mobiles, tablets and desktops screens. By using the snippet above, you've just created a responsive layout for your
website, which will be displayed perfectly on all kind of devices! </p>
<p>But what these elements actually do?</p>
<p class="h5 mt-4">Container </p>
<p>Bootstrap requires a containing element to wrap site contents and house our grid system. You may choose one of two containers:</p>
<p><code><div class="container-fluid"></code> - will display your content on full available width</p>
<p><code><div class="container"></code> - will center your content and give it an appropriate side margins. In the
current project, we are going to use this one.</p>
<p class="h5 mt-4">Row </p>
<p>Rows create horizontal groups of columns. Therefore, if you want to split your layout horizontally, use <code><div class="row"></code>.</p>
<p class="h5 mt-4">Columns </p>
<p>Bootstrap's grid system allows up to 12 columns across the page. To create a column use a special class <code><div class="col-md-*></code>,
where "*" is the number between 1 and 12.</p>
<img class="img-fluid" src="https://mdbootstrap.com/wp-content/uploads/2016/01/grid.jpg" alt="">
<p class="h5 my-4 text-center">Examples </p>
<p class="h5 my-4">2 columns grid </p>
<div class="row my-2">
<div class="col-md-6 indigo" style="height: 150px;"></div>
<div class="col-md-6 teal" style="height: 150px;"></div>
</div>
<pre class="code-toolbar"><code class="language-markup">
<div class="row">
<div class="col-md-6"> </div>
<div class="col-md-6"> </div>
</div>
</code></pre>
<p class="h5 my-4">3 columns grid </p>
<div class="row my-2">
<div class="col-md-4 indigo" style="height: 150px;"></div>
<div class="col-md-4 teal" style="height: 150px;"></div>
<div class="col-md-4 purple" style="height: 150px;"></div>
</div>
<pre class="code-toolbar"><code class="language-markup">
<div class="row">
<div class="col-md-4"> </div>
<div class="col-md-4"> </div>
<div class="col-md-4"> </div>
</div>
</code></pre>
<p class="h5 my-4">4 columns grid </p>
<div class="row my-2">
<div class="col-md-3 indigo" style="height: 150px;"></div>
<div class="col-md-3 teal" style="height: 150px;"></div>
<div class="col-md-3 purple" style="height: 150px;"></div>
<div class="col-md-3 blue" style="height: 150px;"></div>
</div>
<pre class="code-toolbar"><code class="language-markup">
<div class="col-md-3"> </div>
<div class="col-md-3"> </div>
<div class="col-md-3"> </div>
<div class="col-md-3"> </div>
</code></pre>
<p><strong>Important:</strong> Remember that grid columns should add up to twelve for a row.</p>
<p><strong>Important 2: </strong>If you want to use Bootstrap's grid system you always have to use a basic construction
with the container (or container-fluid) and row. Otherwise, your column won't work properly.</p>
<p>That's very basic info about Bootstrap Grid. Along the tutorial, you will learn more advanced tricks which let you use
the full power of the grid. </p>
<p>Now let's get back to our current project.<strong>Click NEXT LESSON</strong> button to proceed further.</p>
</section>
<!--Section: Tutorial content-->