Mastering Bootstrap 4 - Second Edition
eBook - ePub

Mastering Bootstrap 4 - Second Edition

Benjamin Jakobus, Jason Marah

Share book
  1. English
  2. ePUB (mobile friendly)
  3. Available on iOS & Android
eBook - ePub

Mastering Bootstrap 4 - Second Edition

Benjamin Jakobus, Jason Marah

Book details
Book preview
Table of contents
Citations

About This Book

Build responsive, dynamic, and mobile-first applications on the web with Bootstrap 4About This Book• Master the art of creating highly intuitive and responsive web interfaces with Bootstrap 4• Combine the power of Bootstrap and popular front-end JavaScript frameworks such as Angular and React to build cutting-edge web apps• Infuse your web pages with life and movement using Bootstrap jQuery pluginsWho This Book Is ForThis book targets readers who wish to leverage Bootstrap 4 to create responsive web applications. Basic knowledge of web development concepts and web technologies such as HTML, CSS, and JavaScript is required.What You Will Learn• Create a professional Bootstrap-based website from scratch without using third-party templates• Leverage Bootstrap's powerful grid system• Style various types of content and learn how to build a page's layout from scratch by applying the power of Bootstrap 4• Take advantage of Bootstrap's form helper and contextual classes• Improve your website's overall user experience with headers and footers• Infuse your web pages using Bootstrap jQuery plugins and create your own Bootstrap plugins• Learn what utility classes Bootstrap 4 has to offer, how they are implemented, and the best way to use them.• Create more advanced web interfaces by leveraging the power of accordions, dropdowns, and list groups.• Incorporate Bootstrap into an AngularJS or React application and use Bootstrap components as AngularJS directivesIn DetailBootstrap 4 is a free CSS and JavaScript framework that allows developers to rapidly build responsive web interfaces. This book will help you use and adapt Bootstrap to produce enticing websites that fit your needs.You will build a customized Bootstrap website from scratch, using various approaches to customize the framework with increasing levels of skill. You will get to grips with Bootstrap's key features and quickly discover various ways in which Bootstrap can help you develop web interfaces. Then take a walk through the fundamental features, such as its grid system, global styles, helper classes, and responsive utilities. When you have mastered these, you will discover how to structure page layouts, utilize Bootstrap's various navigation components, use forms, and style different types of content.Among other things, you will also tour the anatomy of a Bootstrap plugin, create your own custom components, and extend Bootstrap using jQuery. You will also understand what utility classes Bootstrap 4 has to offer, and how you can use them effectively to speed up the development of your website.Finally, you will discover how to optimize your website and integrate it with third-party frameworks.By the end of this book, you will have a thorough knowledge of the framework's ins and outs, and will be able to build highly customizable and optimized web interfaces.Style and approachA comprehensive, step-by-step guide to mastering the ins and outs of the Bootstrap framework to produce highly customizable, optimized, and sleek web interfaces.

Frequently asked questions

How do I cancel my subscription?
Simply head over to the account section in settings and click on “Cancel Subscription” - it’s as simple as that. After you cancel, your membership will stay active for the remainder of the time you’ve paid for. Learn more here.
Can/how do I download books?
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
What is the difference between the pricing plans?
Both plans give you full access to the library and all of Perlego’s features. The only differences are the price and subscription period: With the annual plan you’ll save around 30% compared to 12 months on the monthly plan.
What is Perlego?
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Do you support text-to-speech?
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Is Mastering Bootstrap 4 - Second Edition an online PDF/ePUB?
Yes, you can access Mastering Bootstrap 4 - Second Edition by Benjamin Jakobus, Jason Marah in PDF and/or ePUB format, as well as other popular books in Ciencia de la computación & Desarrollo web. We have over one million books available in our catalogue for you to explore.

Information

Year
2018
ISBN
9781788838214

On Navigation, Footers, Alerts, and Content

In the previous chapter, we built our website's basic skeleton. Using Bootstrap's grid system, we structured our website into five distinct sections. We then styled these sections and learned how to use Bootstrap's navbar and tab system to make these sections navigable. In this chapter, we will continue adding to the knowledge obtained in Chapter 3, Building the Layout, by leveraging even more Bootstrap components, adding more content, and streamlining our website's design. We will begin by improving our navbar, and by first learning how to fix its position. We will then use a Bootstrap plugin (Scrollspy) to automatically update the navbar tab item appearance based on the user's navigation. Next, we will customize the website's scrolling behavior, making the transition between sections smoother.
Once we have improved our website's navigation, we will focus on improving and customizing our website's overall look and feel—that is, we will learn how to apply and customize alerts, and how to use buttons, brand images, form validation styles, and progress bars. We will also discover how to style different text elements, use media objects, and apply citations and figures.
As we progress through this chapter, we will be examining each of the aforementioned components individually. This way, we will have the chance to see how they are actually composed under the hood.
To summarize, we shall do the following in this chapter:
  • Learning how to fixate our navbar
  • Using the Bootstrap plugin Scrollspy to improve our website's navigation
  • Using icons to customize and improve the overall design of our website
  • Introducing Bootstrap alerts and customizing them
  • Styling our website's footer
  • Applying buttons to improve our website's overall usability
  • Learning about Bootstrap's form validation styles
  • Discovering Bootstrap's progress bar classes

Fixating the navbar

Our website already looks pretty decent. We have a navigation bar in place, a footer placeholder, and various sections populated with some sample content. However, we are not quite there yet. The website's overall user experience is still a bit edgy and does not yet feel very refined. Take navigation, for instance—while clicking on a navbar link does indeed take the user to the correct section, the navbar disappears once we navigate across the sections. This means that the navbar loses its purpose. It no longer facilitates easy navigation across the different sections of our website. Instead, the user will need to scroll to the top of the page every time they wish to use the navbar. To make the navbar persistent, append navbar-fixed-top to the class attribute of our nav element:
<nav class="navbar navbar-expand-lg navbar-myphoto fixed-top">
...
</nav>
Now save, refresh, and scroll. Voila! Our navbar now remains fixed at the top of our page. The fixed-top works as follows: the element's position is set to fixed. This positions the element relative to the browser window (not relative to other elements), meaning that the element will remain in the same place, regardless of the positioning of other elements on the page—that is, fixed navbars are pulled from the normal flow of the DOM and may require custom CSS.
Furthermore, the element's top is set to 0. This means that the distance between the navbar and the top of the browser window is 0. In addition, fixed-top also changes the element's z-index to 1,030, therefore ensuring that the element will appear above all the other elements on the page (that is, all elements that have a z-index of less than 1,030).
The fixed-top class is defined in _position.scss and looks as follows:
.fixed-top {
position: fixed;
top: 0;
right: 0;
left: 0;
z-index: $zindex-fixed;
}
Note: $zindex-fixed is defined in _variables.scss, and its default value is 1030.
Did you know that within web development, another term for persistent is sticky? For example, instead of asking "How can I make my navbar persistent?", you often hear people asking "How do I make my navbar sticky?". Note that position: fixed is not the same as position: sticky. The latter isn't fully supported in every browser.
Should you desire to fixate the navbar at the bottom of the page, you can use the fixed-bottom class. This class behaves in exactly the same way as the fixed-top class, except that instead of setting the element's top to 0, it sets the bottom property to 0, thereby ensuring that the element resides at the bottom of the page.

More on navbar styling

If we wanted to quickly change the color of the navbar without wanting to write a whole bunch of custom rules, then we could apply the navbar-* and bg-* classes:
  • navbar-dark: This is used to indicate that the navbar's foreground color should be adjusted to match a dark background. As such, the rule will apply a white foreground color to all navbar items.
  • navbar-light: This is the opposite of the aforementioned navbar-dark and applies a dark foreground color in order to support a light background.
  • bg-*: This will set the background color to that of the desired context class (we will cover the various context classes later on in this chapter); for example, bg-primary, bg-success, and bg-info; bg-dark mimics an inverted background, setting the background color to #343a40.
Take a look at figure 4.1:
Figure 4.1: The MyPhoto navbar with three dierent context styles: pg-primary, bg-warning, and bg-danger

Improving navigation using S...

Table of contents