-
Notifications
You must be signed in to change notification settings - Fork 0
/
script_12.txt
2294 lines (1973 loc) · 174 KB
/
script_12.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
____________________________________________________________________________
12_css_frameworks_bootstrap_______________________________________________12
____________________________________________________________________________
So we are done with our main CSS content. Now we're going to talk about a third party library called Bootstrap. What is it? Well bootstrap calls itself "the world's most popular CSS Framework". Bootstrap is like a skeleton, it helps us quickly create nice lookin, responsive, modern websites. So we don't have to write as much CSS as we might have to. It provides the framerwork, or the starting point for all sorts of different websites. To get more specific, it consists of two main things: it consists firstly of a collection of components, different pieces that we can use, just insert into our app like a button that's premade, navbars and so on. Secondly it consists of the grid system, on which we'll spend a good amount of time on. This helps us layout our website.
Let's have a look at some componennts from bootstrap. https://getbootstrap.com/docs/5.1/components/buttons/ on the left side we have different components that we can get like buttons. We can get them very easily. You don't have to do anything except include Bootstrap in your document and create a button with a particular class name. So no styles have to be written in order to get these buttons. We also have things like navbars: https://getbootstrap.com/docs/5.1/components/navbar/ here are some examples. What's here nice is that they are responsive, so as we resize the window, they collapse and we get a hamburger icon. Creating that requires a lot of CSS and a good amount of JavaScript, you have to know what you're doing, it takes time, it's a decent amount of code, but if you use Boostrap, you get it for free. There are also Forms: https://getbootstrap.com/docs/5.1/forms/overview/ nice looking forms, different inputs, things like responsive forms so that they change when we resize. These are all things we can actually do on our own. But it's just that it's faster and simpler if we use a tool like Bootstrap. That doesn't mean that we should always rely on something like Boostrap. But it's important for us to understand that they are out there and we should feel comfortable using at least one of these tools. There are other tools like: foundation, semantic ui etc. They all serve the same purpose: they'll give you this foundation, this basic set of tools to create websites.
So now let's talk about the grid system quickly. One of the most annoying parts of creating modern websites is laying out your content, div'ing up space. If we look on the boostrap website we see that there is a small amount of content on the left, a larger piece in the middle and a smaller part on the right. When we make the window smaller, the right side dissapears or goes below at some point and as we continue to shrink everything down, at some point it all collapses into the navbar and the whole layout changes. https://getbootstrap.com/docs/5.1/layout/grid/ The grid system is a bunch of CSS that is prewritten for us where we can relay on some particular classes like "row" and "col". Or more detailed ones like "col-4" or "col-sm-4" where sm stands for small. These all have to do with size, the amount of space that we want to be taken up by certain elements at different screen sizes. So we can easily say that we want one thing to take more space on a large size and less space on a smaller size or vice-versa. If we look at the "mix and match" example from the boostrap website and we make the windows smaller we see that in the beginning we had three things in the middle row that shared the space equally and as we shrunk it down, now they each take out half the space going across. Okay, that's really the point of the grid system: to help you layout your websites and let them have pieces take up space and redistribute that space depending on screen sizes.
What many people ask is: aren't all websites going to look the same if we're all using websites. Yes, they could but they don't have to. They might all have navbars and buttons but things can definitely be customized. You can also omit them entirely and just use the grid system to space out things. We can also do a grid system with flexbox but bootstrap makes it easier and faster for us. So our goal is to spend some time with boostrap. There's a lot to cover but most of it is very very easy. So we're going to focus on the essentials so that we can get building nice responsive modern websites relatively quickly.
Alright, the first thing we need to do is learn how to include Boostrap. It's just as if we would include a stylesheet in our document just like we've been doing for "app.css", but instead of a stylesheet we're writing, it's going to be a stylesheet from Bootstrap. There's a little bit more to it because Boostrap actually does come with some JavaScript too but the core mechanic, the most important piece is a single stylesheet. If we go to Getting started>introduction https://getbootstrap.com/docs/5.1/getting-started/introduction/ there are a couple of different options for how we include the Bootstrap stylesheet and the JavaScript scripts. One option is to download everything onto our machine and link to it as with "app.css" where it needs to be in the same folder or accessible with the correct path to find the file. The easier option to get started right now is to use something called the CDN - which stands for Content Delivery Network. Which is basically a hosted version of a stylesheet that we can access remotely and we don't have to download it on our machines. So if we copy the link tag from the website:
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
and we can actually open it and we see that it's compressed down: all the whitespace is removed but we can see some CSS in there. It's just a massive chunk of CSS. Let's add it in our starter file in basics_starter/index.html So we can add that in our index.html in the <head></head> and it will download the correct script that we need. We'll going to put it before our custom "app.css" stylesheet. That way we can write our own styles and they won't be undone or overwritten by Bootstrap. If Bootstrap made our h1 10px and we make it 20px in our app.css file, it will overwrite it.
At the time of making of this course the version was v5. If we are now at 5.6 for example, there are no major changes but if we are at v6.x there will be some significant changes.
Ok. Let's add some Placeholder stuff. Let's add an h1 and a paragraph with some lorem ipsum.
<h1>Placeholder</h1>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Facere eaque, in autem cupiditate quasi
neque hic
minus
harum perferendis repellendus eos suscipit? Sunt laborum deserunt ea autem totam illum modi!Nobis expedita,
inventore provident reiciendis nostrum impedit, sunt magnam, labore ipsum sequi incidunt! Corrupti esse
harum
nesciunt soluta placeat, voluptates illo accusantium quam fuga ducimus quaerat minus laudantium, quo odit!
</p>
If we comment out the bootstrap link and we refresh we notice that we have different fonts and that some of the margin and padding is different. It's not that important because we can change all of this, what's important is that this tells us that boostrap is working.
Now the other things we should mention is that there are these scripts from the quickstart. https://getbootstrap.com/docs/5.1/getting-started/introduction/ We haven't covered scripts yet but we'll get there. If we want to have access of every part of boostrap, we need to include those scripts too. So certain components require JavaScript such as the: image carousel, collapsable navbar, tooltips and popovers, dropdown menus and so on. Just to be comprehensive we're going to put them in our index.html. The place we're going to put the scripts is at the very bottom right before the closing body tag.
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"
integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj"
crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js"
integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo"
crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"
integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI"
crossorigin="anonymous"></script>
</body>
Okay, so that's what we need to do in order to set up boostrap. Everytime we need to use it, we need that CSS file and optionally the scripts if you need to use certain components. It's better for real production applications to download the Bootstrap CSS file to our computer as the server might go down and we will not have access to the stylesheet. We now have Boostrap included in our document.
Let's have a look at our first component, our first piece of Boostrap syntax. We saw that there are some default font changes, size, margin and padding. But most of what we do in boostrap is enacted therough classes. Every component that we see there on their website like dropdowns https://getbootstrap.com/docs/5.1/components/dropdowns/ we're writing a buch of class="something" a lot of classes sometimes. These are all classes that are predefined in the Boostrap stylesheet. We're basically doing the same thing as with app.css but somebody else wrote it. The first component we'll have a look at is under layout and it's called a container. It's a very simple one but a very important one https://getbootstrap.com/docs/5.1/layout/containers/ A container is the most basic layout element in Bootstrap and it is required when using the default grid system. We'll get soon to the grid system. So what a container does is that it contains and pads content withing it. It's a quick way to get some space and contain our content. Right now the content goes all the way across the screen and usually that's not what we want for a website, we might have different pieces of content, it doesn't just go all the way across. So the container class, the simplest possible container, give us a responsive, fixed-width container. We'll talk about what that means later, but let's try it now. It does not have to be a div but the docs use divs a lot so we'll stick with that too. So let's put a div with class container around all of our content, excluding the script tag at the end:
<div class="container">
<h1>Placeholder</h1>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Facere eaque, in autem cupiditate quasi
neque hic
minus
harum perferendis repellendus eos suscipit? Sunt laborum deserunt ea autem totam illum modi!Nobis expedita,
inventore provident reiciendis nostrum impedit, sunt magnam, labore ipsum sequi incidunt! Corrupti esse
harum
nesciunt soluta placeat, voluptates illo accusantium quam fuga ducimus quaerat minus laudantium, quo odit!
</p>
</div>
After a refresh we can see that there is a bunch of margin now around our content. As we resize, the space changes because there are breakpoints in there. They are predefined in boostrap. We have small, medium, large and so on. We'll get back to that when we get to the grid system. Another thing we'll look into is "container-fluid". This is going to be a full width container and it will span the entire width of the viewport, so basically all the way across. Unlike what we have right now, which goes all the way across only when we are on an extra-small screen size. So let's change that to container-fluid to see it's effect:
<div class="container-fluid">
<h1>Placeholder</h1>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Facere eaque, in autem cupiditate quasi
neque hic
minus
harum perferendis repellendus eos suscipit? Sunt laborum deserunt ea autem totam illum modi!Nobis expedita,
inventore provident reiciendis nostrum impedit, sunt magnam, labore ipsum sequi incidunt! Corrupti esse
harum
nesciunt soluta placeat, voluptates illo accusantium quam fuga ducimus quaerat minus laudantium, quo odit!
</p>
</div>
Now as we resize, our container goes all the way across the screen the entire time. There's still some margin so it's not like there's no container at all. It still makes a difference compared to what we had without the container. But certainly it's not the same as just container. The last thing we'll look here at is the responsive versions like: "container-sm", -md, -lg-, xl and what these we'll do is allow us to say: we want the container to be all the way across the screen, 100% wide until you hit the small breakpoint, the large or the extra large, depending on what you have selected. Let's see that quickly by setting it to container-md (meaning medium):
<div class="container-md">
<h1>Placeholder</h1>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Facere eaque, in autem cupiditate quasi
neque hic
minus
harum perferendis repellendus eos suscipit? Sunt laborum deserunt ea autem totam illum modi!Nobis expedita,
inventore provident reiciendis nostrum impedit, sunt magnam, labore ipsum sequi incidunt! Corrupti esse
harum
nesciunt soluta placeat, voluptates illo accusantium quam fuga ducimus quaerat minus laudantium, quo odit!
</p>
</div>
We start all the way across the screen and after we hit the breakpoint, it goes back to acting like the original container, just a plain container. This is getting a bit in the weeds but they are very simple. For the most part we'll use container and container-fluid. And the default container is full-width on very small screens and then it adds a bunch of margin on other sizes. So we're always going to work within a container. We don't have to for most of boostrap but for the grid system we need to work in a container. So that was the idea of setting up boostrap and the most basic boostrap component: the container which we give to elements by stating class="container". Let's set the container-md back to container on our div:
<div class="container">
<h1>Placeholder</h1>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Facere eaque, in autem cupiditate quasi
neque hic
minus
harum perferendis repellendus eos suscipit? Sunt laborum deserunt ea autem totam illum modi!Nobis expedita,
inventore provident reiciendis nostrum impedit, sunt magnam, labore ipsum sequi incidunt! Corrupti esse
harum
nesciunt soluta placeat, voluptates illo accusantium quam fuga ducimus quaerat minus laudantium, quo odit!
</p>
</div>
Next up we'll have a look at more exciting components: buttons. https://getbootstrap.com/docs/5.1/components/buttons/ On the left side of the page we have the different components we can look at and on the right side there are the individual sections of the current page we're looking at. So Bootstrap comes with its default styles which we will use for now. They are customizable though. So everything we have to do with buttons will involve a class named "btn" and then different variations of that. Even with the variations we will still see the "btn". So let's pick one of them to start. Let's copy one of them into our index.html to see if it works. Let's put it under our h1 to begin with.
<button type="button" class="btn btn-primary">Primary</button>
So very different than just a typical button if we added it wit
<button>Primary</button>
The Bootstrap one looks nicer. Now what's up with "btn-primary", "btn-success" and so on? Bootstrap comes with these different semantic colors, labelled: primary, secondary, success, danger, warning, info, light, dark and link. These are used all over the place. They are also used in alerts for example. If we look under utilites, which we will get back too, we have different a set of color utilities so that we can make different background colors, for example. They all have those same labels. These colors are not set in stone, we can change them. The point of having a "success" is not to have a green color necessarily, or that danger is supposed to be red. Those are just the default colors that come with Bootstrap. And the point it that semantics are just a meaning. So it's pretty common for a website to have a primary color like a brand color and then some secondary color that goes along with it and then some color that indicates that something is going horribly wrong: a danger versus a successful or warning which is not the same as danger. We can change them all up. As an example, the navbar from the Boostrap website is using a purple color as the primary color for their website. So they changed that. If we inspect with f12 a button on boostrap we should see a "primary" class on it. So don't get hung up on the specific colors, they are just built in options that we can customize and really, it's just about the meaning behind those terms and labels. Instead of assumig that every website is going to have a red and a green they instead just go with some primary color, some secondary color, some warning color and so on. Ok that's enough around colors.
So we can make all those variations. Let's make a couple more buttons to see how they work. Let's make a "btn-success" and a "btn-info" alongside our existing one. Let's also change the text between the tags accordingly:
<button type="button" class="btn btn-primary">Primary</button>
<button type="button" class="btn btn-success">Success</button>
<button type="button" class="btn btn-info">Info</button>
We won't do every possible option but keep in mind that there are more than these three. We have different options. We can use those classes on anchor tags, too, to make a button. Also on input where class="btn btn-primary" for example (see Boostrap website example on buttons). We also have outline variations of buttons which are different looking. They have the same colors but the syntax or better said the actual class name is different: "btn btn-outline-primary". Let's add one for warning in our index.html after our normal buttons:
<button type="button" class="btn btn-primary">Primary</button>
<button type="button" class="btn btn-success">Success</button>
<button type="button" class="btn btn-info">Info</button>
<button class="btn btn-outline-warning">Warning Outline</button>
Now we get this inverted highlight effect when we hover over. Let's add two more for "btn-outline-danger":
<button type="button" class="btn btn-primary">Primary</button>
<button type="button" class="btn btn-success">Success</button>
<button type="button" class="btn btn-info">Info</button>
<button class="btn btn-outline-warning">Warning Outline</button>
<button class="btn btn-outline-danger">Danger Outline</button>
Let's make something very clear about Boostrap is that whenever we are using it, unless we are super-experienced and we have an amazing mind for memorization, we're going to consult the docs. It's just a part of it. So don't get hung up trying to memorize this. Just like with CSS and especially with Boostrap in particular there's just a lot here. If you mispell stuff just slightly, we don't get any of the effects of that class and the browser will actually return no error. So we have to keep an eye out for that, too. Copy and paste is totally fine. Ok let's see what we can do with sizes, let's make a "btn btn-outline-info btn-lg" button:
<button type="button" class="btn btn-primary">Primary</button>
<button type="button" class="btn btn-success">Success</button>
<button type="button" class="btn btn-info">Info</button>
<button class="btn btn-outline-warning">Warning Outline</button>
<button class="btn btn-outline-danger">Danger Outline</button>
<button class="btn btn-outline-info btn-lg">Info Outline</button>
It's not massive but it is larger than the others. Let's do one more of class "btn btn-secondary btn-sm":
<button type="button" class="btn btn-primary">Primary</button>
<button type="button" class="btn btn-success">Success</button>
<button type="button" class="btn btn-info">Info</button>
<button class="btn btn-outline-warning">Warning Outline</button>
<button class="btn btn-outline-danger">Danger Outline</button>
<button class="btn btn-outline-info btn-lg">Info Outline</button>
<button class="btn btn-secondary btn-sm">SM Button</button>
This makes us a small secondary button. We can also make block buttons without having to change the disaply property ourselves, but that's all it's going to do for us: set the display to block. We also have active state, disabled state so they will have different styles if we add the disabled attribute. This is kind of nice as it will reflect the current color of the button. Let's make one "btn btn-success" disabled.
<button type="button" class="btn btn-primary">Primary</button>
<button type="button" class="btn btn-success">Success</button>
<button type="button" class="btn btn-info">Info</button>
<button class="btn btn-outline-warning">Warning Outline</button>
<button class="btn btn-outline-danger">Danger Outline</button>
<button class="btn btn-outline-info btn-lg">Info Outline</button>
<button class="btn btn-secondary btn-sm">SM Button</button>
<button type="button" class="btn btn-success" disabled>Success Disabled</button>
It gets slightly grayed out and less saturated. So that's all styles coming from Boostrap. So that's it for buttons. Remember: these colors can change, it's the meaning behind them that matters. They are just labels, they are like slots for different colors that we can fill in at will and make our own palette. So this was our first example of using the sort of Boostrap mechanic: a bunch of classes. We saw a "btn" and then some option for color, if it is outline, what it's size is, if it is a block and so on.
Now we'll talk briefly about typography in Bootstrap. This is not under Components. This is under Content>Typography https://getbootstrap.com/docs/5.1/content/typography/ This page tells us a bit about some of the global change that have been made like the global font-size, the background color and so on. If we scroll down there are a couple of things we should pay attention to. First of all, the "display" classes. There are four of them: display-1, display-2, display-3 and display-4. They are used to make large headers. They are not responsive by default but we can change that. So let's use it in our h1 in the index.html file and let's add an h2 with class "display-4" that says "Buttons" just under the h1.
<h1 class="display-1">Bootstrap Playground</h1>
<h2 class="display-4">Buttons</h2>
<button type="button" class="btn btn-primary">Primary</button>
<button type="button" class="btn btn-success">Success</button>
<button type="button" class="btn btn-info">Info</button>
<button class="btn btn-outline-warning">Warning Outline</button>
<button class="btn btn-outline-danger">Danger Outline</button>
<button class="btn btn-outline-info btn-lg">Info Outline</button>
<button class="btn btn-secondary btn-sm">SM Button</button>
<button type="button" class="btn btn-success" disabled>Success Disabled</button>
These "display-4" are just different sizes. They don't have to indicate meaning like: the h2 should be a subheader of h1, a sublevel of headings. Let's add another h2 of class display-4 just above our paragraph and have it say "Typography".
<h1 class="display-1">Bootstrap Playground</h1>
<h2 class="display-4">Buttons</h2>
<button type="button" class="btn btn-primary">Primary</button>
<button type="button" class="btn btn-success">Success</button>
<button type="button" class="btn btn-info">Info</button>
<button class="btn btn-outline-warning">Warning Outline</button>
<button class="btn btn-outline-danger">Danger Outline</button>
<button class="btn btn-outline-info btn-lg">Info Outline</button>
<button class="btn btn-secondary btn-sm">SM Button</button>
<button type="button" class="btn btn-success" disabled>Success Disabled</button>
<h2 class="display-4">Typography</h2>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Facere eaque, in autem cupiditate quasi
neque hic
minus
harum perferendis repellendus eos suscipit? Sunt laborum deserunt ea autem totam illum modi!Nobis expedita,
inventore provident reiciendis nostrum impedit, sunt magnam, labore ipsum sequi incidunt! Corrupti esse
harum
nesciunt soluta placeat, voluptates illo accusantium quam fuga ducimus quaerat minus laudantium, quo odit!
</p>
Alright. Aside from what we saw so far we also have the "lead" class. It's description is that it makes a paragraph stand out if we add the class="lead" to it. So let's add it to our paragraph.
<h1 class="display-1">Bootstrap Playground</h1>
<h2 class="display-4">Buttons</h2>
<button type="button" class="btn btn-primary">Primary</button>
<button type="button" class="btn btn-success">Success</button>
<button type="button" class="btn btn-info">Info</button>
<button class="btn btn-outline-warning">Warning Outline</button>
<button class="btn btn-outline-danger">Danger Outline</button>
<button class="btn btn-outline-info btn-lg">Info Outline</button>
<button class="btn btn-secondary btn-sm">SM Button</button>
<button type="button" class="btn btn-success" disabled>Success Disabled</button>
<h2 class="display-4">Typography</h2>
<p class="lead">Lorem ipsum dolor sit amet consectetur adipisicing elit. Facere eaque, in autem cupiditate quasi
neque hic
minus
harum perferendis repellendus eos suscipit? Sunt laborum deserunt ea autem totam illum modi!Nobis expedita,
inventore provident reiciendis nostrum impedit, sunt magnam, labore ipsum sequi incidunt! Corrupti esse
harum
nesciunt soluta placeat, voluptates illo accusantium quam fuga ducimus quaerat minus laudantium, quo odit!
</p>
This changes the font-size and font-weight so make it stand out a bit more. That is supposed to be the tagline or the lead text of a page. There are also blockquotes. Let's add a blackquote with a <p></p> inside it after our paragraph and add some lorem text into the <p></p> tags:
<h1 class="display-1">Bootstrap Playground</h1>
<h2 class="display-4">Buttons</h2>
<button type="button" class="btn btn-primary">Primary</button>
<button type="button" class="btn btn-success">Success</button>
<button type="button" class="btn btn-info">Info</button>
<button class="btn btn-outline-warning">Warning Outline</button>
<button class="btn btn-outline-danger">Danger Outline</button>
<button class="btn btn-outline-info btn-lg">Info Outline</button>
<button class="btn btn-secondary btn-sm">SM Button</button>
<button type="button" class="btn btn-success" disabled>Success Disabled</button>
<h2 class="display-4">Typography</h2>
<p class="lead">Lorem ipsum dolor sit amet consectetur adipisicing elit. Facere eaque, in autem cupiditate quasi
neque hic
minus
harum perferendis repellendus eos suscipit? Sunt laborum deserunt ea autem totam illum modi!Nobis expedita,
inventore provident reiciendis nostrum impedit, sunt magnam, labore ipsum sequi incidunt! Corrupti esse
harum
nesciunt soluta placeat, voluptates illo accusantium quam fuga ducimus quaerat minus laudantium, quo odit!
</p>
<blockquote>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Est ab sed iusto alias numquam
ipsum tenetur
error nostrum similique sunt, quod deserunt totam pariatur consequatur ad exercitationem et ea odio?</p>
</blockquote>
We can also give it a class of blockquote:
<h1 class="display-1">Bootstrap Playground</h1>
<h2 class="display-4">Buttons</h2>
<button type="button" class="btn btn-primary">Primary</button>
<button type="button" class="btn btn-success">Success</button>
<button type="button" class="btn btn-info">Info</button>
<button class="btn btn-outline-warning">Warning Outline</button>
<button class="btn btn-outline-danger">Danger Outline</button>
<button class="btn btn-outline-info btn-lg">Info Outline</button>
<button class="btn btn-secondary btn-sm">SM Button</button>
<button type="button" class="btn btn-success" disabled>Success Disabled</button>
<h2 class="display-4">Typography</h2>
<p class="lead">Lorem ipsum dolor sit amet consectetur adipisicing elit. Facere eaque, in autem cupiditate quasi
neque hic
minus
harum perferendis repellendus eos suscipit? Sunt laborum deserunt ea autem totam illum modi!Nobis expedita,
inventore provident reiciendis nostrum impedit, sunt magnam, labore ipsum sequi incidunt! Corrupti esse
harum
nesciunt soluta placeat, voluptates illo accusantium quam fuga ducimus quaerat minus laudantium, quo odit!
</p>
<blockquote class="blockquote">
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Est ab sed iusto alias numquam
ipsum tenetur
error nostrum similique sunt, quod deserunt totam pariatur consequatur ad exercitationem et ea odio?</p>
</blockquote>
This makes it a little heavier, bolder and slightly larger. Then what's nice is that we have an easy way of adding in a footer. They use a footer element for semantics in the Boostrap docs but we can use anything. We'll stick for now with the docs and give it a class="blockquote-footer", let's also give it a text of "Mr. Lorem Ipsum":
<h1 class="display-1">Bootstrap Playground</h1>
<h2 class="display-4">Buttons</h2>
<button type="button" class="btn btn-primary">Primary</button>
<button type="button" class="btn btn-success">Success</button>
<button type="button" class="btn btn-info">Info</button>
<button class="btn btn-outline-warning">Warning Outline</button>
<button class="btn btn-outline-danger">Danger Outline</button>
<button class="btn btn-outline-info btn-lg">Info Outline</button>
<button class="btn btn-secondary btn-sm">SM Button</button>
<button type="button" class="btn btn-success" disabled>Success Disabled</button>
<h2 class="display-4">Typography</h2>
<p class="lead">Lorem ipsum dolor sit amet consectetur adipisicing elit. Facere eaque, in autem cupiditate quasi
neque hic
minus
harum perferendis repellendus eos suscipit? Sunt laborum deserunt ea autem totam illum modi!Nobis expedita,
inventore provident reiciendis nostrum impedit, sunt magnam, labore ipsum sequi incidunt! Corrupti esse
harum
nesciunt soluta placeat, voluptates illo accusantium quam fuga ducimus quaerat minus laudantium, quo odit!
</p>
<blockquote class="blockquote">
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Est ab sed iusto alias numquam
ipsum tenetur
error nostrum similique sunt, quod deserunt totam pariatur consequatur ad exercitationem et ea odio?</p>
<footer class="blockquote-footer">Mr. Lorem Ipsum</footer>
</blockquote>
Now it's grayed out and it give us a dash in front of the text and we didn't do anything: we didn't tell it to be gray or to have the dash. That's just the default style. If we notice on the boostrap website there is a class="mb-0" added to the paragraph of the blockquote. Even though we haven't covered it yet we can put that in there too.
<blockquote class="blockquote">
<p class="mb-0">Lorem ipsum dolor sit amet consectetur adipisicing elit. Est ab sed iusto alias numquam
ipsum tenetur
error nostrum similique sunt, quod deserunt totam pariatur consequatur ad exercitationem et ea odio?</p>
<footer class="blockquote-footer">Mr. Lorem Ipsum</footer>
</blockquote>
This is an easy way to add margin at the bottom. Or in this case removing it by setting it to 0.
Next we have different utilities, different ways of aligning text. If we want something to be centered, we can just add "text-center". If we want it right aligned we can just add "text-right". Let's do that on the entire blockquote:
<blockquote class="blockquote text-right">
<p class="mb-0">Lorem ipsum dolor sit amet consectetur adipisicing elit. Est ab sed iusto alias numquam
ipsum tenetur
error nostrum similique sunt, quod deserunt totam pariatur consequatur ad exercitationem et ea odio?</p>
<footer class="blockquote-footer">Mr. Lorem Ipsum</footer>
</blockquote>
We can easily achieve that through our own CSS so there's nothing revolutionary here. Let's add it to our h1 and make it text-center:
<h1 class="display-1 text-center">Bootstrap Playground</h1>
<h2 class="display-4">Buttons</h2>
<button type="button" class="btn btn-primary">Primary</button>
<button type="button" class="btn btn-success">Success</button>
<button type="button" class="btn btn-info">Info</button>
<button class="btn btn-outline-warning">Warning Outline</button>
<button class="btn btn-outline-danger">Danger Outline</button>
<button class="btn btn-outline-info btn-lg">Info Outline</button>
<button class="btn btn-secondary btn-sm">SM Button</button>
<button type="button" class="btn btn-success" disabled>Success Disabled</button>
<h2 class="display-4">Typography</h2>
<p class="lead">Lorem ipsum dolor sit amet consectetur adipisicing elit. Facere eaque, in autem cupiditate quasi
neque hic
minus
harum perferendis repellendus eos suscipit? Sunt laborum deserunt ea autem totam illum modi!Nobis expedita,
inventore provident reiciendis nostrum impedit, sunt magnam, labore ipsum sequi incidunt! Corrupti esse
harum
nesciunt soluta placeat, voluptates illo accusantium quam fuga ducimus quaerat minus laudantium, quo odit!
</p>
<blockquote class="blockquote text-right">
<p class="mb-0">Lorem ipsum dolor sit amet consectetur adipisicing elit. Est ab sed iusto alias numquam
ipsum tenetur
error nostrum similique sunt, quod deserunt totam pariatur consequatur ad exercitationem et ea odio?</p>
<footer class="blockquote-footer">Mr. Lorem Ipsum</footer>
</blockquote>
Obviously we could do that on our own like we can do pretty much all of the stuff we've covered here so far. But it makes our life easier, it's just a class that we are adding on. The idea of Boostrap is to make it faster and easier for us to get those styles.
Next up, we'll go to Utilities. Utilities help us center something, change the color, add a border or change it's display property or position property, add a shadow and so on. They are not necessarily components, they don't stand alone, we add them to something. So we'll start with Utilities>Colors. https://getbootstrap.com/docs/5.1/utilities/colors/ we have a lot of options to change the color of text: text-primary, text-secondary and all other semantic color names that we've seen so far. If we want to make something "info" coloured, we can do "text-info". Let's do that to our h1:
<h1 class="display-1 text-center text-primary">Bootstrap Playground</h1>
<h2 class="display-4">Buttons</h2>
<button type="button" class="btn btn-primary">Primary</button>
<button type="button" class="btn btn-success">Success</button>
<button type="button" class="btn btn-info">Info</button>
<button class="btn btn-outline-warning">Warning Outline</button>
<button class="btn btn-outline-danger">Danger Outline</button>
<button class="btn btn-outline-info btn-lg">Info Outline</button>
<button class="btn btn-secondary btn-sm">SM Button</button>
<button type="button" class="btn btn-success" disabled>Success Disabled</button>
And this makes it the primary color which happens to be the default blue. We also have the other ones like "succes, danger, warning, info" and so on. Hopefully that's self explainatory. We also have background colors like: bg-primary and then often we'll use a light text on top like text-white. So let's make something have a background here. Let's add for example the bg-light to our blockquote:
<blockquote class="blockquote text-right bg-light">
<p class="mb-0">Lorem ipsum dolor sit amet consectetur adipisicing elit. Est ab sed iusto alias numquam
ipsum tenetur
error nostrum similique sunt, quod deserunt totam pariatur consequatur ad exercitationem et ea odio?</p>
<footer class="blockquote-footer">Mr. Lorem Ipsum</footer>
</blockquote>
Alright, we'll leave it at that. We can mix and match like give something a dark background colour and a white text or danger background color and warning text. So these are some utilities: color and background color.
So far we've learnend a decent amount about text utilities, text-alignment, display classes, blockquote and then all the text utilities for color.
Next up we'll look at more components. The first one we'll look at is a badge component https://getbootstrap.com/docs/5.1/components/badge/ and it's typically used for displaying a count 1, 2, 3 and so one or some sort of label. That's kind of all you use it for. You can mix and match it in the heading, you can put it in the button. You can also make one that's rounded. All that they are is a <span></span> with a class of "badge" and a color. Also notice that they scale based on the element they are inside of. Let's add a badge in our display-4 h2 with color badge-success and let's put a text called "New" inside the span:
<h1 class="display-1 text-center text-primary">Bootstrap Playground</h1>
<h2 class="display-4">Buttons <span class="badge badge-success">New</span></h2>
<button type="button" class="btn btn-primary">Primary</button>
<button type="button" class="btn btn-success">Success</button>
<button type="button" class="btn btn-info">Info</button>
<button class="btn btn-outline-warning">Warning Outline</button>
<button class="btn btn-outline-danger">Danger Outline</button>
<button class="btn btn-outline-info btn-lg">Info Outline</button>
<button class="btn btn-secondary btn-sm">SM Button</button>
<button type="button" class="btn btn-success" disabled>Success Disabled</button>
Another useful place to use badges is in a navbar situation if there is an alert or in some sort of button to display the number of notifications or updates or changes. Let's do an example of that. Let's add a primary button with a badge inside: let's set the text to be Updates on the button and give the badge a badge-light color and an inside text of 9:
<h1 class="display-1 text-center text-primary">Bootstrap Playground</h1>
<h2 class="display-4">Buttons <span class="badge badge-success">New</span></h2>
<button type="button" class="btn btn-primary">Primary</button>
<button type="button" class="btn btn-success">Success</button>
<button type="button" class="btn btn-info">Info</button>
<button class="btn btn-outline-warning">Warning Outline</button>
<button class="btn btn-outline-danger">Danger Outline</button>
<button class="btn btn-outline-info btn-lg">Info Outline</button>
<button class="btn btn-secondary btn-sm">SM Button</button>
<button type="button" class="btn btn-success" disabled>Success Disabled</button>
<button class="btn btn-primary">Updates <span class="badge badge-light">9</span></button>
So there we go, there's our little badge. We also have the ability to make one of them a pill. This just gives it a border radius on the corner. Let's try badge-pill on one of our badges. Let's put it on our h2's badge:
<h1 class="display-1 text-center text-primary">Bootstrap Playground</h1>
<h2 class="display-4">Buttons <span class="badge badge-success badge-pill">New</span></h2>
<button type="button" class="btn btn-primary">Primary</button>
<button type="button" class="btn btn-success">Success</button>
<button type="button" class="btn btn-info">Info</button>
<button class="btn btn-outline-warning">Warning Outline</button>
<button class="btn btn-outline-danger">Danger Outline</button>
<button class="btn btn-outline-info btn-lg">Info Outline</button>
<button class="btn btn-secondary btn-sm">SM Button</button>
<button type="button" class="btn btn-success" disabled>Success Disabled</button>
<button class="btn btn-primary">Updates <span class="badge badge-light">9</span></button>
So that's all there is to badges. Very simple. Another component we'll take a look at now is the button group https://getbootstrap.com/docs/5.1/components/button-group/ This will group multiple buttons together into a group. This is pretty common to use nice looking selects where an user picks one option instead of a radio button or a group of radio buttons. We're not going to worry about how that works because it involves some JavaScript, we're only going to look at the syntax. So if we have one than one button and we group them, we will give that containing element the class "btn-group" and it will significantly alter things. So let's an h3 saying "Button Groups" and let's make three buttons after it with class of btn-warning:
<h1 class="display-1 text-center text-primary">Bootstrap Playground</h1>
<h2 class="display-4">Buttons <span class="badge badge-success badge-pill">New</span></h2>
<button type="button" class="btn btn-primary">Primary</button>
<button type="button" class="btn btn-success">Success</button>
<button type="button" class="btn btn-info">Info</button>
<button class="btn btn-outline-warning">Warning Outline</button>
<button class="btn btn-outline-danger">Danger Outline</button>
<button class="btn btn-outline-info btn-lg">Info Outline</button>
<button class="btn btn-secondary btn-sm">SM Button</button>
<button type="button" class="btn btn-success" disabled>Success Disabled</button>
<button class="btn btn-primary">Updates <span class="badge badge-light">9</span></button>
<h3>Button Groups</h3>
<button class="btn btn-warning">One</button>
<button class="btn btn-warning">Two</button>
<button class="btn btn-warning">Three</button>
So no group yet, they are all separate buttons. Now we're going to group them together with that class of btn-group used by a div which will surround the three buttons:
<h1 class="display-1 text-center text-primary">Bootstrap Playground</h1>
<h2 class="display-4">Buttons <span class="badge badge-success badge-pill">New</span></h2>
<button type="button" class="btn btn-primary">Primary</button>
<button type="button" class="btn btn-success">Success</button>
<button type="button" class="btn btn-info">Info</button>
<button class="btn btn-outline-warning">Warning Outline</button>
<button class="btn btn-outline-danger">Danger Outline</button>
<button class="btn btn-outline-info btn-lg">Info Outline</button>
<button class="btn btn-secondary btn-sm">SM Button</button>
<button type="button" class="btn btn-success" disabled>Success Disabled</button>
<button class="btn btn-primary">Updates <span class="badge badge-light">9</span></button>
<h3>Button Groups</h3>
<div class="btn-group">
<button class="btn btn-warning">One</button>
<button class="btn btn-warning">Two</button>
<button class="btn btn-warning">Three</button>
</div>
Now they are a single group. It changes what those buttons looked like: we don't have margin inbetween them, the border radius changes and they are not curved on the inside, just the outside edges have that curve. So that's kind of cool. This can expand as many times as we want, we can change colors and so on. So that's button group. There is some important stuff around accessibility that we should be aware of here. If we are going to use these buttons in a group to make some sort of fancy radio button or a select instead of having three separate radio buttons, if they are somehow associated in a way where you are only supposed to pick one or they are different options for something, we should give the containing element the attribute role="group". This is going to indicate the screen readers that this is a group of buttons.
We can also make toolbars, we can also nest them, we can nest them and change their size with "btn-group-lg", "btn-group-sm" and so on. These are not something we need to spend a ton of time on but they're here and this is your brief intro. So that's button groups.
Another component we'll look at is the alert. https://getbootstrap.com/docs/5.1/components/alerts/ alerts is supposed to provide some sort of feedback to your user: after some action, or when the page loads like "this was saved." or "this failed to save" or "you don't have permission to do that" or "welcome back" or "you have logged out" and that sort of thing. They can be used for other purposes but that's the main goal: to alert the user about something important or it doesn't have to be crucial but just bring the user's attention to some piece of information. The way that we do this is similar to buttons. We need a div or some element with the class of "alert" as the base class and then the color variant: alert-primary, alert-secondary and so on just as with buttons. This is the simplest one. Let's add one in our index.html. Let's add an <h3></h3> that says "Alerts" and then after it we'll do a div of class="alert alert-danger". Inside the div we'll put some text. We can also put other elements inside the alert if we wanted to like buttons. But let's put some basic text like: "Danger! You are about to end the world as we know it!"
<h3>Button Groups</h3>
<div class="btn-group">
<button class="btn btn-warning">One</button>
<button class="btn btn-warning">Two</button>
<button class="btn btn-warning">Three</button>
</div>
<h3>Alerts</h3>
<div class="alert alert-danger">
Danger! You are about to end the world as we know it!
</div>
So that's one option. Of course we can change it to success, primary and so on. What we'd like to see here is that we can actually make them dismissable, we can add extra content and we can also have an alert heading. Let's also add an alert heading as an h4 with the class of "alert-heading" and the text "Oh No!":
<h3>Button Groups</h3>
<div class="btn-group">
<button class="btn btn-warning">One</button>
<button class="btn btn-warning">Two</button>
<button class="btn btn-warning">Three</button>
</div>
<h3>Alerts</h3>
<div class="alert alert-danger">
<h4 class="alert-heading">Oh No!</h4>
Danger! You are about to end the world as we know it!
</div>
Alright, let's now have a look a dismissable alerts. As on the Boostrap website, we can make an alert that has that x button and we can make it so that it actually dismisses the alert. Now, that involves some JavaScript. Fortunately we don't have to write any of it, but we do have to do something we have not yet seen. So we'll build this up one piece at a time and all we have to do to begin with is add in our button. This button can look like anything but typically we'll use an x. The x is not the letter x, it's a close icon and we can just use the letter x but a lot of people like to use the entity code to make the times symbol. That is × and is different from the normal x. So let's put that inside of a button and put a span with the entity for times inside it. We'll also add the aria-hidden="true" attribute from the website too:
<h3>Button Groups</h3>
<div class="btn-group">
<button class="btn btn-warning">One</button>
<button class="btn btn-warning">Two</button>
<button class="btn btn-warning">Three</button>
</div>
<h3>Alerts</h3>
<div class="alert alert-danger">
<h4 class="alert-heading">Oh No!</h4>
Danger! You are about to end the world as we know it!
<button>
<span aria-hidden="true">×</span>
</button>
</div>
The aria-hidden attribute means that on screen readers, this does not need to be showing up at all, because a screen reader does not know what this is. So in order for the screen reader to read the corect thing we need to add the attribute aria-label="Close" to our button:
<h3>Button Groups</h3>
<div class="btn-group">
<button class="btn btn-warning">One</button>
<button class="btn btn-warning">Two</button>
<button class="btn btn-warning">Three</button>
</div>
<h3>Alerts</h3>
<div class="alert alert-danger">
<h4 class="alert-heading">Oh No!</h4>
Danger! You are about to end the world as we know it!
<button aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
Now it looks kind of looks bad. So we can add the class="close" to our button to make it look better:
<h3>Alerts</h3>
<div class="alert alert-danger">
<h4 class="alert-heading">Oh No!</h4>
Danger! You are about to end the world as we know it!
<button aria-label="Close" class="close">
<span aria-hidden="true">×</span>
</button>
</div>
So we made it look better but it's still not going to close it. So in order for that to work, we need to add a data-dismiss="alert" attribute. This comes from Boostrap. It is not something we have access to on any button we make.
<h3>Alerts</h3>
<div class="alert alert-danger">
<h4 class="alert-heading">Oh No!</h4>
Danger! You are about to end the world as we know it!
<button aria-label="Close" class="close" data-dismiss="alert">
<span aria-hidden="true">×</span>
</button>
</div>
So it does work, right away, we are able to dismiss. There is another thing we can do. We can actually add in to this alert "alert-dismissible fade show" classes:
<h3>Alerts</h3>
<div class="alert alert-danger alert-dismissible fade show">
<h4 class="alert-heading">Oh No!</h4>
Danger! You are about to end the world as we know it!
<button aria-label="Close" class="close" data-dismiss="alert">
<span aria-hidden="true">×</span>
</button>
</div>
This is going to move the x up to the top right corner and it adds some nice little fade out instead of it being immediately removed. This is a reasonably large amount of classes compared to what we've seen but it's just from the docs. What we're still missing is the role="alert", let's add that attribute to our alert too:
<h3>Alerts</h3>
<div class="alert alert-danger alert-dismissible fade show" role="alert">
<h4 class="alert-heading">Oh No!</h4>
Danger! You are about to end the world as we know it!
<button aria-label="Close" class="close" data-dismiss="alert">
<span aria-hidden="true">×</span>
</button>
</div>
This is very important for accessibility as it indicates to the screen reader that this is important information. Often these alerts will show on the page after the page has loaded. We'll do something and the alert appears. If we're looking at it it's easy to see there's stuff on the screen but most screen readers are not going to read out content that changes or just shows up unless we add on this role="alert". Again, we can copy and paste from the docs at any point if we are ever confused or we're not sure how these alerts work or any of these other things work. If we don't have JavaScript, the Bootstrap JavaScript files down at the bottom, this is not going to work at all. We still get the alert but it doesn't dismiss anymore. That's all thanks to the Bootstrap JavaScript file and the other two dependencies, about which we won't worry about now. So keep that in mind if you didn't include those scripts and you tried to make a dimissable alert, it won't work unless you do have those scripts.
We're going to take a break from the components side of things to talk about the grid system. We still have more components like form, inputs, navbars to talk about, but the grid is a nice distraction as it's easy and really useful. So we'll have a look at it now and not at the end. The grid system helps us lay out our content on a webpage and it helps us create responsive layouts where the division of space might change depending on a screen size. We've seen this before but watch how https://getbootstrap.com/docs/4.0/layout/grid/ everything shifts around depending on the screen size. The grid system works upon a couple of really important concepts: the first thing we have to understand is that it only works inside of a container. So we have to have a container or more than one container on a page, but there has to be a container class anytime we want to use a grid. The next thing we need to know is that we need to create a row using the class of "row". Let's now jump into our grid_starter/index.html file. This is a pretty empty html document where we've got Bootstrap included, a container and a heading. Now let's add a div with a class of "row" after the heading and inside the div class="container".
<body>
<div class="container">
<h1 class="display-1 text-center text-primary">The Grid System</h1>
<div class="row">
</div>
</div>
This is not going to do much for us, but the content will go inside there. This is the most imporant piece to understand: every row in Bootstrap has 12 units of space to divvy up. So on the bootstrap website there are boxes that take 50% and 50% of line space: those are 6 units each. If you have 3 blocks each taking equal space then block are 4 units each and so on. The total is always 12 units.
The next thing to know is that we need to create columns in our row. So that every piece that we want to divvy up in a row is going to be a column. There are a couple of different classes that we'll see but they all start with "col". For example "col-sm-4", "col-sm" or "col-4". These are all column classes that begin with "col". Alright so we'll see now the first most basic way of dividing up space using classes "col-" and then a number afterwards. So for example if we wanted 50% and 50% we'd do col-6 and col-6. Let's add two divs with col-6 one with bg-success and the other with bg-info with the containing text saying "I AM 6 UNITS"
<body>
<div class="container">
<h1 class="display-1 text-center text-primary">The Grid System</h1>
<div class="row">
<div class="col-6 bg-success">I AM 6 UNITS</div>
<div class="col-6 bg-info"></div>
</div>
</div>
So that's all twelve units. Now we can shift that around. We're not going to change the text right away. We'll just change the numbers and the bg-info to bg-danger. Let's do the first col- div col-4 and the second col-8
<body>
<div class="container">
<h1 class="display-1 text-center text-primary">The Grid System</h1>
<div class="row">
<div class="col-4 bg-success">I AM 6 UNITS</div>
<div class="col-8 bg-danger"></div>
</div>
</div>
or we can do col-2 and col-8:
<body>
<div class="container">
<h1 class="display-1 text-center text-primary">The Grid System</h1>
<div class="row">
<div class="col-2 bg-success">I AM 6 UNITS</div>
<div class="col-8 bg-danger"></div>
</div>
</div>
if we do that we're going to have extra space over there that's not being used. That's fine, we'll talk later about what we can do with extra space like center things, add that space between our columns and so on. We can add another one at the end with class col-2 and bg-success and change the text between the tags according to the size
<body>
<div class="container">
<h1 class="display-1 text-center text-primary">The Grid System</h1>
<div class="row">
<div class="col-2 bg-success">I AM 2 UNITS</div>
<div class="col-8 bg-danger">I AM 8 UNITS</div>
<div class="col-2 bg-success">I AM 2 UNITS</div>
</div>
</div>
now this adds up to twelve. We can also add another row down below and have something entirely different. A row is just twelve units going across the screen and we can divide let's do the new row col-6, col-3 and col-3 and give them bg-info, bg-warning and bg-info.
<body>
<div class="container">
<h1 class="display-1 text-center text-primary">The Grid System</h1>
<div class="row">
<div class="col-2 bg-success">I AM 2 UNITS</div>
<div class="col-8 bg-danger">I AM 8 UNITS</div>
<div class="col-2 bg-success">I AM 2 UNITS</div>
</div>
<div class="row">
<div class="col-3 bg-info">I AM 3 UNITS</div>
<div class="col-6 bg-warning">I AM 6 UNITS</div>
<div class="col-3 bg-info">I AM 3 UNITS</div>
</div>
</div>
So they still add up to twelve. We can put whatever content we want inside those columns, not just background color and text. We can put form elements if we want a nice form that we can lay out, we can put images and other components we have yet to see like cards. We can actually get a little bit lazier than this and say if we want equally sized columns we can do class="col" and if there are two of them they will split the space 6-6, if there are three: 4-4-4. It will automatically figure out how much space each of them needs. So let's add some right now, let's make a new div class="row" and add three divs with class="col" and bg-primary, bg-secondary and bg-primary colors. Let's have the text in the middle of the div say "I AM AUTO SIZED".
<body>
<div class="container">
<h1 class="display-1 text-center text-primary">The Grid System</h1>
<div class="row">
<div class="col-2 bg-success">I AM 2 UNITS</div>
<div class="col-8 bg-danger">I AM 8 UNITS</div>
<div class="col-2 bg-success">I AM 2 UNITS</div>
</div>
<div class="row">
<div class="col-3 bg-info">I AM 3 UNITS</div>
<div class="col-6 bg-warning">I AM 6 UNITS</div>
<div class="col-3 bg-info">I AM 3 UNITS</div>
</div>
<div class="row">
<div class="col bg-primary">I AM AUTO SIZED</div>
<div class="col bg-secondary">I AM AUTO SIZED</div>
<div class="col bg-primary">I AM AUTO SIZED</div>
</div>
</div>
If we double take a div out or add one more, they will still share the space equally. What's intereseting is that we can make one "col-10" for example and it will be 9 units and it will not autosize while the others will have to figure out for themselves how to split up the remaining space. This shows that we can do a mixture of autosized and sized columns.
Alright so to recap the basics here: you need to have a container. That container can also be a fluid container - which is a full-width container - and we can nest containers inside of containers. Then we create our rows. A row is something with a class of row, typically a div. It can also be a section. It doesn't really represent anything itself. It's just there to help spread out or structure the content or lay it out. We have twelve units withing each row. We can divide those up however we want. We use "col-" and some number to create our column sizes or just "col" to create an automatically sized or autosized column that will share the space that is left over if we have some already divvied up like did in our example.
Now we get into the meat of the grid system. The most important part, the most exciting part, which is how we can create responsive layouts and shift content around based upon the screen size. So the way that we do this hinges upon the built in breakpoints in Boostrap. We briefly talked about them, they are different sizes that are predefined. So we have small 576-768px, below 576px is considered extra small. We also have medium large and xl for greater than 1200px wide. These are all predefined sizes and we can reference them at any point using the grid system. So we can have a 50-5 split on large and xl screens but on medium small and xs we might have 12 units and 12 units, in other words two full rows instead of sharing any space. There are a bunch of classes that help us do this. They all use these breakpoint sizes in the class names. We have things like "col-8" as we've seen but we also have "col-sm-8" or "col-lg-6". Let's demonstrate this by making a new section in our index.html. Let's first make an h2 with class "display-4" which says "Responsive Grid". Below that let's add a div with class row:
<div class="row">
<div class="col bg-primary">I AM AUTO SIZED</div>
<div class="col bg-secondary">I AM AUTO SIZED</div>
<div class="col bg-primary">I AM AUTO SIZED</div>
</div>
<h2 class="display-4">Responsive Grid</h2>
<div class="row"></div>
</div>
Inside the class="row" div we'll put two divs of class col-6 to make them 50-50 with some lorem ipsum text inside them:
<div class="row">
<div class="col bg-primary">I AM AUTO SIZED</div>
<div class="col bg-secondary">I AM AUTO SIZED</div>
<div class="col bg-primary">I AM AUTO SIZED</div>
</div>
<h2 class="display-4">Responsive Grid</h2>
<div class="row">
<div class="col-6">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Dolor consequatur voluptatem eligendi ducimus.
Expedita quia omnis, at itaque illo nemo dolorem aperiam. Rerum magnam eveniet dicta vel rem dolorem
voluptatem.
</div>
<div class="col-6">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Dolor consequatur voluptatem eligendi ducimus.
Expedita quia omnis, at itaque illo nemo dolorem aperiam. Rerum magnam eveniet dicta vel rem dolorem
voluptatem.
</div>
</div>
</div>
Alright, what if we want them at the small and below breakpoint to go all the way across on their own and not share space anymore. What we can do then is use "col-md-6" on them. Let's add it to them:
<div class="row">
<div class="col bg-primary">I AM AUTO SIZED</div>
<div class="col bg-secondary">I AM AUTO SIZED</div>
<div class="col bg-primary">I AM AUTO SIZED</div>
</div>
<h2 class="display-4">Responsive Grid</h2>
<div class="row">
<div class="col-md-6">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Dolor consequatur voluptatem eligendi ducimus.
Expedita quia omnis, at itaque illo nemo dolorem aperiam. Rerum magnam eveniet dicta vel rem dolorem
voluptatem.
</div>
<div class="col-md-6">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Dolor consequatur voluptatem eligendi ducimus.
Expedita quia omnis, at itaque illo nemo dolorem aperiam. Rerum magnam eveniet dicta vel rem dolorem
voluptatem.
</div>
</div>
</div>
The way we would read this "col-md-6" is: after the medium breakpoint and up, it should take up six units, everything below is assumed that it goes all the way across. So if we shrink the page down, they stack and as we make it larger, they take 6 units of space each. Let's give them a bg-info and bg-success to them to see them better.
<div class="row">
<div class="col bg-primary">I AM AUTO SIZED</div>
<div class="col bg-secondary">I AM AUTO SIZED</div>
<div class="col bg-primary">I AM AUTO SIZED</div>
</div>
<h2 class="display-4">Responsive Grid</h2>
<div class="row">
<div class="col-md-6 bg-info">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Dolor consequatur voluptatem eligendi ducimus.
Expedita quia omnis, at itaque illo nemo dolorem aperiam. Rerum magnam eveniet dicta vel rem dolorem
voluptatem.
</div>
<div class="col-md-6 bg-success">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Dolor consequatur voluptatem eligendi ducimus.
Expedita quia omnis, at itaque illo nemo dolorem aperiam. Rerum magnam eveniet dicta vel rem dolorem
voluptatem.
</div>
</div>
</div>
So we have all these different sizes. Let's say we have four of them. Let's add two more divs by copying the last two and pasting them in:
<div class="row">
<div class="col bg-primary">I AM AUTO SIZED</div>
<div class="col bg-secondary">I AM AUTO SIZED</div>
<div class="col bg-primary">I AM AUTO SIZED</div>
</div>
<h2 class="display-4">Responsive Grid</h2>
<div class="row">
<div class="col-md-6 bg-info">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Dolor consequatur voluptatem eligendi ducimus.
Expedita quia omnis, at itaque illo nemo dolorem aperiam. Rerum magnam eveniet dicta vel rem dolorem
voluptatem.
</div>
<div class="col-md-6 bg-success">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Dolor consequatur voluptatem eligendi ducimus.
Expedita quia omnis, at itaque illo nemo dolorem aperiam. Rerum magnam eveniet dicta vel rem dolorem
voluptatem.
</div>
<div class="col-md-6 bg-info">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Dolor consequatur voluptatem eligendi ducimus.
Expedita quia omnis, at itaque illo nemo dolorem aperiam. Rerum magnam eveniet dicta vel rem dolorem
voluptatem.
</div>
<div class="col-md-6 bg-success">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Dolor consequatur voluptatem eligendi ducimus.
Expedita quia omnis, at itaque illo nemo dolorem aperiam. Rerum magnam eveniet dicta vel rem dolorem
voluptatem.
</div>
</div>
</div>
So let's say we wanted to have four across when we made the screen larger. We can achieve this by adding "col-xl-3".
<div class="row">
<div class="col bg-primary">I AM AUTO SIZED</div>
<div class="col bg-secondary">I AM AUTO SIZED</div>
<div class="col bg-primary">I AM AUTO SIZED</div>
</div>
<h2 class="display-4">Responsive Grid</h2>
<div class="row">
<div class="col-md-6 col-xl-3 bg-info">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Dolor consequatur voluptatem eligendi ducimus.
Expedita quia omnis, at itaque illo nemo dolorem aperiam. Rerum magnam eveniet dicta vel rem dolorem
voluptatem.
</div>
<div class="col-md-6 col-xl-3 bg-success">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Dolor consequatur voluptatem eligendi ducimus.
Expedita quia omnis, at itaque illo nemo dolorem aperiam. Rerum magnam eveniet dicta vel rem dolorem
voluptatem.
</div>
<div class="col-md-6 col-xl-3 bg-info">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Dolor consequatur voluptatem eligendi ducimus.
Expedita quia omnis, at itaque illo nemo dolorem aperiam. Rerum magnam eveniet dicta vel rem dolorem
voluptatem.
</div>
<div class="col-md-6 col-xl-3 bg-success">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Dolor consequatur voluptatem eligendi ducimus.
Expedita quia omnis, at itaque illo nemo dolorem aperiam. Rerum magnam eveniet dicta vel rem dolorem
voluptatem.
</div>
</div>
</div>
Now they go all the way across at small, we hit medium and they go 50-50, we go xl and they go 3-3-3-3 which adds up to twelve. So we read "col-xl-3" as do whatever until width size xl and then from there occupy 3 units. And we apply this to our four divs. If we were to overflow this: this means giving each of them "col-xl-4" this means that the four of them will not fit on the page. The last one will be put on a separate row. We can try this now. But still the same principle applies when we go from small to medium and from medium to xl as they change their spacing. We can specify sizes however we like. Often what we do is have them get smaller or take up less space as the screen gets wider. It's not that common to have the inverse relationship. Usually on a wider screen, our elements don't need that much room versus on a smaller screen we'll have them take up more units of space across the row.
Let's do one more example here. Let's add a new div class="row" and put three images in there with img:
<div class="row">
<img src="https://images.unsplash.com/photo-1589595363745-d842812a9db7?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=800&q=60"
alt="">
<img src="https://images.unsplash.com/photo-1511692277506-3be3a7ab1686?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=800&q=60"
alt="">
<img src="https://images.unsplash.com/photo-1497206365907-f5e630693df0?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=800&q=60"
alt="">
</div>
Take these links, they are some free images from unsplash. Now we're going to use a new class that we have not yet seen for responsive images. It's called "img-fluid". It's pretty straightforward, it makes the image scale based upon the size of its containing element. So if we put a "img-fluid" inside a column and that column changes size, the image changes size too. So let's give them all a class of "img-fluid" and wrap each one in a div with class="col"
<div class="row">
<div class="col">
<img class="img-fluid" src="https://images.unsplash.com/photo-1589595363745-d842812a9db7?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=800&q=60"
alt="">
</div>
<div class="col">
<img class="img-fluid" src="https://images.unsplash.com/photo-1511692277506-3be3a7ab1686?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=800&q=60"
alt="">
</div>
<div class="col">
<img class="img-fluid" src="https://images.unsplash.com/photo-1497206365907-f5e630693df0?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=800&q=60"
alt="">
</div>
</div>
Now they are all in a column, equally sized. They are not responsive yet. A quick note: if you are using different images and they are different heights, they're not going to be the same height in your row. You can change how your image displays. We are using here three square images but we're focusing on the width, the amount of space they take out horizontally, anyway. So what we'd like to do now is have them go three in a row on extra large and large but then two across on medium and then just one across for smaller. So let's add "col-xl-4" to our images' divs for extra large so that we have three across on size xl or greater than xl.
<div class="row">
<div class="col col-xl-4">
<img class="img-fluid" src="https://images.unsplash.com/photo-1589595363745-d842812a9db7?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=800&q=60"
alt="">
</div>
<div class="col col-xl-4">
<img class="img-fluid" src="https://images.unsplash.com/photo-1511692277506-3be3a7ab1686?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=800&q=60"
alt="">
</div>
<div class="col col-xl-4">
<img class="img-fluid" src="https://images.unsplash.com/photo-1497206365907-f5e630693df0?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=800&q=60"
alt="">
</div>
</div>
Now we want something inbetween because just before the xl breakpoint, the images are kind of large. The images are cropped to 800px width from unsplash and in the case of other images which are larger than that they would just occupy the whole width of the screen if smaller than extra large. So let's make them take up from medium and above six units. That would be "col-md-6" to be added to all three images' divs class:
<div class="row">
<div class="col col-xl-4 col-md-6">
<img class="img-fluid" src="https://images.unsplash.com/photo-1589595363745-d842812a9db7?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=800&q=60"
alt="">
</div>
<div class="col col-xl-4 col-md-6">
<img class="img-fluid" src="https://images.unsplash.com/photo-1511692277506-3be3a7ab1686?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=800&q=60"
alt="">
</div>
<div class="col col-xl-4 col-md-6">
<img class="img-fluid" src="https://images.unsplash.com/photo-1497206365907-f5e630693df0?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=800&q=60"
alt="">
</div>
</div>
This give full width across on small up until medium class where we go 50% with 6 units then we go to 4 units from xl. One other thing to mention here is the gutter, the spacing, there is a variation of the grid, or of the row rather where we can mention a class called "no-gutters" (see docs page), if we wanted to eliminate the space inbetween. If we wanted to use it we would need to write "row no-gutters". But it looks kind nice with them there so we'll keep them as they are for now.
Alright this was our intro to responsive classes for our grid system. Remember: 12 units which we can divvy them up however we want and we can do that on a breakpoint basis. So from small and above I want this or rather from medium and above take up six units and actually from xl and above I want four. So it's alwasy from this breakpoint and above unless we specify something else.
Next up we'll have a look at some helper classes, some nice utilities that we can use to align our content. So a couple of things upfront: one, remember our flex-box, we talked about flex-box and terms like align-items, justify-content and so on, well those are actually used in boostrap. Boostrap uses flex-box terminology because it's actually built on top of flex-box. Let's actually get something to align right now. Let's put the following code just after the "Responsive Grid" div and make an h2 that says "Grid Alignment". After that we'll make four one div with class="row" and inside it four other divs with lorem ipsum inside them and give them a class="col-3". The first one should have bg-danger, the next one bg-warning, the next bg-success and the last bg-info.
<h2>Grid Alignment</h2>
<div class="row">
<div class="col-3 bg-danger">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Maxime quos quam minus recusandae nisi culpa,
in eius beatae quae blanditiis aliquam. Eum cumque ut atque fuga dolorem fugiat est suscipit.
</div>
<div class="col-3 bg-warning">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Maxime quos quam minus recusandae nisi culpa,
in eius beatae quae blanditiis aliquam. Eum cumque ut atque fuga dolorem fugiat est suscipit.
</div>
<div class="col-3 bg-success">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Maxime quos quam minus recusandae nisi culpa,
in eius beatae quae blanditiis aliquam. Eum cumque ut atque fuga dolorem fugiat est suscipit.
</div>
<div class="col-3 bg-info">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Maxime quos quam minus recusandae nisi culpa,
in eius beatae quae blanditiis aliquam. Eum cumque ut atque fuga dolorem fugiat est suscipit.
</div>
</div>
They are all lorem ipsum and are exactly the same height. Let's make one of them twice the height. Let's try the success one. Let's add one more lorem ipsum in there:
<h2>Grid Alignment</h2>
<div class="row">
<div class="col-3 bg-danger">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Maxime quos quam minus recusandae nisi culpa,
in eius beatae quae blanditiis aliquam. Eum cumque ut atque fuga dolorem fugiat est suscipit.
</div>
<div class="col-3 bg-warning">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Maxime quos quam minus recusandae nisi culpa,
in eius beatae quae blanditiis aliquam. Eum cumque ut atque fuga dolorem fugiat est suscipit.
</div>
<div class="col-3 bg-success">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Maxime quos quam minus recusandae nisi culpa,
in eius beatae quae blanditiis aliquam. Eum cumque ut atque fuga dolorem fugiat est suscipit. Lorem
ipsum dolor sit amet consectetur adipisicing elit. Similique, blanditiis nisi fugiat vel unde ratione
aliquam incidunt provident sit, voluptates excepturi aspernatur aliquid ullam eaque eum nobis hic,
delectus corporis!
</div>
<div class="col-3 bg-info">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Maxime quos quam minus recusandae nisi culpa,
in eius beatae quae blanditiis aliquam. Eum cumque ut atque fuga dolorem fugiat est suscipit.
</div>
</div>
Alright now we have some extra space. We can see now theat they are all growing to take up that same height as that green box. Maybe that's not what we want, maybe we want all the other ones to be aligned at the top and to not stretch to take up that whole height, or maybe we want them to be centered, or maybe we want them aligned to the bottom. Well fortunately we have these classes we can use: align-items-start, align-items-center, align-items-end. With these classes we can vertically align our content. Thinking back to flex-box, how align items works: it works in the cross axis (which here is up and down). Our grid is built using flex-box already because we have the class of the main div set to "row" and if we inspect it with f12, we'll see that it has display: flex set to it. This gets set automatically when we put class="row" to our div. So we could manually go in and set the actual CSS that says align-items: center or align-items: start and so on. Or we can use the flex-box helpers. So that's what we're going to do. So first let's find the row div and set the align-items-center on it.
<h2>Grid Alignment</h2>
<div class="row align-items-center">
<div class="col-3 bg-danger">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Maxime quos quam minus recusandae nisi culpa,
in eius beatae quae blanditiis aliquam. Eum cumque ut atque fuga dolorem fugiat est suscipit.
</div>
<div class="col-3 bg-warning">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Maxime quos quam minus recusandae nisi culpa,
in eius beatae quae blanditiis aliquam. Eum cumque ut atque fuga dolorem fugiat est suscipit.
</div>
<div class="col-3 bg-success">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Maxime quos quam minus recusandae nisi culpa,
in eius beatae quae blanditiis aliquam. Eum cumque ut atque fuga dolorem fugiat est suscipit. Lorem
ipsum dolor sit amet consectetur adipisicing elit. Similique, blanditiis nisi fugiat vel unde ratione
aliquam incidunt provident sit, voluptates excepturi aspernatur aliquid ullam eaque eum nobis hic,
delectus corporis!
</div>
<div class="col-3 bg-info">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Maxime quos quam minus recusandae nisi culpa,
in eius beatae quae blanditiis aliquam. Eum cumque ut atque fuga dolorem fugiat est suscipit.
</div>
</div>
We can also set it to align-items-end, or align-items-start. Center is used pretty frequently if we have content that is not exactly the same size, if we're making a product card where there are three subscription choices and there's information about each one, we can center align them together. So if we made the yellow - warning one - three times larger with lorem*2. It should look decent. Let's try it now:
<h2>Grid Alignment</h2>
<div class="row align-items-center">
<div class="col-3 bg-danger">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Maxime quos quam minus recusandae nisi culpa,
in eius beatae quae blanditiis aliquam. Eum cumque ut atque fuga dolorem fugiat est suscipit.
</div>
<div class="col-3 bg-warning">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Maxime quos quam minus recusandae nisi culpa,
in eius beatae quae blanditiis aliquam. Eum cumque ut atque fuga dolorem fugiat est suscipit. Lorem
ipsum dolor sit amet, consectetur adipisicing elit. Nisi quidem adipisci deleniti voluptatum sapiente
autem, veniam nostrum ipsum voluptatibus, voluptas non soluta accusantium amet suscipit, sint veritatis
dolorum commodi asperiores!Minima, id, a doloremque corporis qui non laborum reiciendis, at
necessitatibus harum dolorem tenetur quos nesciunt ratione aliquam aperiam beatae dolor nam. Iste
similique sequi vitae nesciunt cumque! Distinctio, assumenda?
</div>
<div class="col-3 bg-success">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Maxime quos quam minus recusandae nisi culpa,
in eius beatae quae blanditiis aliquam. Eum cumque ut atque fuga dolorem fugiat est suscipit. Lorem
ipsum dolor sit amet consectetur adipisicing elit. Similique, blanditiis nisi fugiat vel unde ratione
aliquam incidunt provident sit, voluptates excepturi aspernatur aliquid ullam eaque eum nobis hic,
delectus corporis!
</div>
<div class="col-3 bg-info">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Maxime quos quam minus recusandae nisi culpa,
in eius beatae quae blanditiis aliquam. Eum cumque ut atque fuga dolorem fugiat est suscipit.
</div>
</div>
So that's align items. Just like in flex-box, we can also control the alignment of a single column using align-self. We have align-self-start, align-self-center and align-self-end. Let's demonstrate this on our example, by aligning the blue one to the end:
<h2>Grid Alignment</h2>
<div class="row align-items-center">
<div class="col-3 bg-danger">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Maxime quos quam minus recusandae nisi culpa,
in eius beatae quae blanditiis aliquam. Eum cumque ut atque fuga dolorem fugiat est suscipit.
</div>
<div class="col-3 bg-warning">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Maxime quos quam minus recusandae nisi culpa,
in eius beatae quae blanditiis aliquam. Eum cumque ut atque fuga dolorem fugiat est suscipit. Lorem
ipsum dolor sit amet, consectetur adipisicing elit. Nisi quidem adipisci deleniti voluptatum sapiente
autem, veniam nostrum ipsum voluptatibus, voluptas non soluta accusantium amet suscipit, sint veritatis
dolorum commodi asperiores!Minima, id, a doloremque corporis qui non laborum reiciendis, at
necessitatibus harum dolorem tenetur quos nesciunt ratione aliquam aperiam beatae dolor nam. Iste
similique sequi vitae nesciunt cumque! Distinctio, assumenda?