npm
. Here we need the following command: npm install bootstrap
<head>
: <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
rem
are used, while the units of measurement used in the past are px
. Here you can learn about how they differ..xs
class no longer exists)..row
class to the main element of the page <div>
. When adjusting the sizes of nested elements, the following classes are used (instead of the asterisk at the end of the class name, the number of columns of the basic 12-column grid is indicated, which a particular element should occupy):col-lg-*
is a class used for pages intended for devices with large screens, like laptops;col-md-*
is a class for pages designed for devices with a medium-sized screen, such as tablets;col-sm-*
- class for pages that are designed small screens, for example, such as smartphones..navbar
class. In fact, this is the wrapper into which the elements forming the navigation bar are placed. Below is a panel that we will create now. It is located at the top of the page and does not disappear when scrolling..navbar
add a <nav>
tag to the index.html
with the class .navbar
, inside of which, using other classes like .navbar-brand
, .navbar-toggler
and .nav-item
, create some special elements and structure of the site navigation system. The .fixed-top
class allows you to lock the navigation bar at the top of the page. Here is the layout of the navigation bar: <nav class="navbar navbar-expand-lg fixed-top "> <a class="navbar-brand" href="#">Home</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-4"> <li class="nav-item"> <a class="nav-link" href="#">About</a> </li> <li class="nav-item"> <a class="nav-link " href="#">Portfolio</a> </li> <li class="nav-item"> <a class="nav-link " href="#">Team</a> </li> <li class="nav-item"> <a class="nav-link " href="#">Post</a> </li> <li class="nav-item"> <a class="nav-link " href="#">Contact</a> </li> </ul> </div> </nav>
main.css
file and connect it to the page by placing the following in the <head>
the index.html
file: <link rel="stylesheet" type="text/css" href="css/main.css">
.navbar{ background:#F97300; } .nav-link , .navbar-brand{ color: #f4f4f4; cursor: pointer; } .nav-link{ margin-right: 1em !important; } .nav-link:hover{ background: #f4f4f4; color: #f97300; } .navbar-collapse{ justify-content: flex-end; } .navbar-toggler{ background:#fff !important; }
justify-content
property and set its value at flex-end
: .navbar-collapse{ justify-content: flex-end; }
.bg-light
(light background), .bg-dark
(dark background), and .bg-primary
(primary background color) classes to customize the background color of the navigation pane. We use the following settings: .bg-dark{ background-color:#343a40!important } .bg-primary{ background-color:#343a40!important }
<header>
use the <header>
: <header class="header"> </header>
main.js
file and connect it to the index.html
before the closing <body>
: <script type="text/javascript" src='js/main.js'></script>
main.js
file: $(document).ready(function(){ $('.header').height($(window).height()); })
/*header style*/ .header{ background-image: url('../images/headerback.jpg'); background-attachment: fixed; background-size: cover; background-position: center; }
.overlay
add a <div>
element to it, assigning the .overlay
class to .overlay
, which will lead to the creation of a block that is located on top of the background image of the header. Let's change that section of the index.html
file, where we described the header, as follows: <header class="header"> <div class="overlay"></div> </header>
main.css
, add the following: .overlay{ position: absolute; min-height: 100%; min-width: 100%; left: 0; top: 0; background: rgba(244, 244, 244, 0.79); }
<div>
element with the class .containter
. This is an auxiliary class of the framework called Bootstrap, which is designed to host content based on the needs of a responsive layout. Here's how the markup changes in this step: <header class="header"> <div class="overlay"></div> <div class="container"> </div> </header>
<div>
element to which we assign the .description
class: <div class="description text-center"> <h3><font color="#3AC1EF">▍ Hello ,Welcome To My officail Website <p> cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p> <button class="btn btn-outline-secondary">See more</button> </font></h3> </div>
.text-center
this tag, which will allow aligning its contents to the center of the page. At the end of the site description there is a button. Talk about how to set it up..btn
and .btn
to the <button>
.btn
. btn-outline-secondary
..description
class: .description{ position: absolute; top: 30%; margin: auto; padding: 2em; } .description h1{ color:#F97300 ; } .description p{ color:#666; font-size: 20px; width: 50%; line-height: 1.5; } .description button{ border:1px solid #F97300; background:#F97300; color:#fff; }
.row
class to the parent element of the <div>
.row
: <div class="row"></div>
<div class="row"> // <div class="col-lg-4 col-md-4 col-sm-12"> <img align="center" src="images/team-3.jpg" class="img-fluid"> <span class="text-justify">S.Web Developer</span> </div> </div>
<div class="row"> <div class="col-lg-4 col-md-4 col-sm-12"> <img align="center" src="images/team-3.jpg" class="img-fluid"> <span class="text-justify">S.Web Developer</span> </div> <div class="col-lg-8 col-md-8 col-sm-12 desc"> <h3><font color="#3AC1EF">▍D.John</font></h3> <p> ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. </p> </div> </div>
col-lg-*
, col-md-*
and col-sm-*
. .about{ margin: 4em 0; padding: 1em; position: relative; } .about h1{ color:#F97300; margin: 2em; } .about img{ height: 100%; width: 100%; border-radius: 50% } .about span{ display: block; color: #888; position: absolute; left: 115px; } .about .desc{ padding: 2em; border-left:4px solid #10828C; } .about .desc h3{ color: #10828C; } .about .desc p{ line-height:2; color:#888; }
<!-- portfolio --> <div class="portfolio"> <h1 class="text-center">Portfolio</h1> <div class="container"> <div class="row"> <div class="col-lg-4 col-md-4 col-sm-12"> <img align="center" src="images/portfolio/port13.png" class="img-fluid"> </div> <div class="col-lg-4 col-md-4 col-sm-12"> <img align="center" src="images/portfolio/port1.png" class="img-fluid"> </div> <div class="col-lg-4 col-md-4 col-sm-12"> <img align="center" src="images/portfolio/port6.png" class="img-fluid"> </div> <div class="col-lg-4 col-md-4 col-sm-12"> <img align="center" src="images/portfolio/port3.png" class="img-fluid"> </div> <div class="col-lg-4 col-md-4 col-sm-12"> <img align="center" src="images/portfolio/port11.png" class="img-fluid"> </div> <div class="col-lg-4 col-md-4 col-sm-12"> <img align="center" src="images/portfolio/electric.png" class="img-fluid"> </div> <div class="col-lg-4 col-md-4 col-sm-12"> <img align="center" src="images/portfolio/Classic.jpg" class="img-fluid"> </div> <div class="col-lg-4 col-md-4 col-sm-12"> <img align="center" src="images/portfolio/port1.png" class="img-fluid"> </div> <div class="col-lg-4 col-md-4 col-sm-12"> <img align="center" src="images/portfolio/port8.png" class="img-fluid"> </div> </div> </div> </div>
.img-fluid
class to each of the images makes them responsive.col-sm-12
used for devices with small screens, the class col-md-4
used for medium screens, col-lg-4
- for devices with large screens). As a result, on large and medium screens, about 33.3% of a container element will fall on one element, on small devices each element will occupy the entire screen (12 columns). /*Portfolio*/ .portfolio{ margin: 4em 0; position: relative; } .portfolio h1{ color:#F97300; margin: 2em; } .portfolio img{ height: 15rem; width: 100%; margin: 1em; }
<div>
element in the layout and add the class .card
to it. The following classes can be used to configure various card elements:.card-header
: .card-header
.card-body
: main content.card-title
: title.card-footer
: basement.card-image
: image <!-- Posts section --> <div class="blog"> <div class="container"> <h1 class="text-center">Blog</h1> <div class="row"> <div class="col-md-4 col-lg-4 col-sm-12"> <div class="card"> <div class="card-img"> <img align="center" src="images/posts/polit.jpg" class="img-fluid"> </div> <div class="card-body"> <h4 class="card-title">Post Title</h4> <p class="card-text"> proident, sunt in culpa qui officia deserunt mollit anim id est laborum. </p> </div> <div class="card-footer"> <a href="" class="card-link">Read more</a> </div> </div> </div> <div class="col-md-4 col-lg-4 col-sm-12"> <div class="card"> <div class="card-img"> <img align="center" src="images/posts/images.jpg" class="img-fluid"> </div> <div class="card-body"> <h4 class="card-title">Post Title</h4> <p class="card-text"> proident, sunt in culpa qui officia deserunt mollit anim id est laborum. </p> </div> <div class="card-footer"> <a href="" class="card-link">Read more</a> </div> </div> </div> <div class="col-md-4 col-lg-4 col-sm-12"> <div class="card"> <div class="card-img"> <img align="center" src="images/posts/imag2.jpg" class="img-fluid"> </div> <div class="card-body"> <h4 class="card-title">Post Title</h4> <p class="card-text"> proident, sunt in culpa qui officia deserunt mollit anim id est laborum. </p> </div> <div class="card-footer"> <a href="" class="card-link">Read more</a> </div> </div> </div> </div> </div> </div>
.blog{ margin: 4em 0; position: relative; } .blog h1{ color:#F97300; margin: 2em; } .blog .card{ box-shadow: 0 0 20px #ccc; } .blog .card img{ width: 100%; height: 12em; } .blog .card-title{ color:#F97300; } .blog .card-body{ padding: 1em; }
<!-- Team section --> <div class="team"> <div class="container"> <h1 class="text-center">Our Team</h1> <div class="row"> <div class="col-lg-3 col-md-3 col-sm-12 item"> <img align="center" src="images/team-2.jpg" class="img-fluid" alt="team"> <div class="des"> Sara </div> <span class="text-muted">Manager</span> </div> <div class="col-lg-3 col-md-3 col-sm-12 item"> <img align="center" src="images/team-3.jpg" class="img-fluid" alt="team"> <div class="des"> Chris </div> <span class="text-muted">S.enginner</span> </div> <div class="col-lg-3 col-md-3 col-sm-12 item"> <img align="center" src="images/team-2.jpg" class="img-fluid" alt="team"> <div class="des"> Layla </div> <span class="text-muted">Front End Developer</span> </div> <div class="col-lg-3 col-md-3 col-sm-12 item"> <img align="center" src="images/team-3.jpg" class="img-fluid" alt="team"> <div class="des"> J.Jirard </div> <span class="text-muted">Team Manger</span> </div> </div> </div> </div>
.team{ margin: 4em 0; position: relative; } .team h1{ color:#F97300; margin: 2em; } .team .item{ position: relative; } .team .des{ background: #F97300; color: #fff; text-align: center; border-bottom-left-radius: 93%; transition:.3s ease-in-out; }
main.css
: .team .item:hover .des{ height: 100%; background:#f973007d; position: absolute; width: 89%; padding: 5em; top: 0; border-bottom-left-radius: 0; }
.form-control
class for input fields, but now there is something new here. For example, instead of the obsolete class .input-group-addon
, a new class .input-group-prepend
(for badges and labels). Details on this can be found in the documentation for Bootstrap 4. In our case, each input field will be placed in a <div>
element to which the class .form-group
is assigned.index.html
file: <!-- Contact form --> <div class="contact-form"> <div class="container"> <form> <div class="row"> <div class="col-lg-4 col-md-4 col-sm-12"> <h1>Get in Touch</h1> </div> <div class="col-lg-8 col-md-8 col-sm-12 right"> <div class="form-group"> <input type="text" class="form-control form-control-lg" placeholder="Your Name" name=""> </div> <div class="form-group"> <input type="email" class="form-control form-control-lg" placeholder="YourEmail@email.com" name="email"> </div> <div class="form-group"> <textarea class="form-control form-control-lg"> </textarea> </div> <input type="submit" class="btn btn-secondary btn-block" value="Send" name=""> </div> </div> </form> </div> </div>
main.css
file: .contact-form{ margin: 6em 0; position: relative; } .contact-form h1{ padding:2em 1px; color: #F97300; } .contact-form .right{ max-width: 600px; } .contact-form .right .btn-secondary{ background: #F97300; color: #fff; border:0; } .contact-form .right .form-control::placeholder{ color: #888; font-size: 16px; }
main.css
file: @import url('https://fonts.googleapis.com/css?family=Raleway');
html,h1,h2,h3,h4,h5,h6,a{ font-family: "Raleway"; }
main.js
file: $(".navbar a").click(function(){ $("body,html").animate({ scrollTop:$("#" + $(this).data('value')).offset().top },1000) })
data-value
attribute to each of the links in the navigation bar and bring the markup to the following form: <li class="nav-item"> <a class="nav-link" data-value="about" href="#">About</a> </li> <li class="nav-item"> <a class="nav-link " data-value="portfolio" href="#">Portfolio</a> </li> <li class="nav-item"> <a class="nav-link " data-value="blog" href="#">Blog</a> </li> <li class="nav-item"> <a class="nav-link " data-value="team" href="#"> Team</a> </li> <li class="nav-item"> <a class="nav-link " data-value="contact" href="#">Contact</a> </li>
id
attribute to the main <div>
element of each section of the page. At the same time, it is necessary to ensure that its value is identical to that specified in the data-value
attribute of the corresponding link. For example, here is the corresponding attribute for the About section: <div class="about" id="about"></div>
Source: https://habr.com/ru/post/350758/
All Articles