- Mastering Bootstrap 4(Second Edition)
- Benjamin Jakobus Jason Marah
- 259字
- 2021-06-24 19:25:53
Image modifiers
Bootstrap also comes with some useful built-in image modifiers, namely, rounded, img-thumbnail, and rounded-circle. Let's apply these to the images in our example:
<div class="container">
<h1>Our Print Sizes</h1>
<div class="row">
<div class="col-sm-3">
<img src="images/small.jpg" class="img-fluid rounded-
circle">
<h5>Small</h5>
...
</div>
<div class="col-sm-3">
<img src="images/medium.jpg" class="img-fluid rounded">
<h5>Medium</h5>
...
</div>
<div class="col-sm-3">
<img src="images/large.jpg" class="img-thumbnail">
<h5>Large</h5>
...
</div>
<div class="col-sm-3 ">
<img src="images/extra-large.jpg" class="img-fluid">
<h5>Extra Large</h5>
...
</div>
</div>
</div>
Take a look at Figure 2.16:

You may note that in the previously mentioned code, for the Small and Medium images, we have kept img-fluid but removed img-fluid from Large. This is because an img-thumbnail actually uses img-fluid as a mixin, while rounded-circle and rounded pay zero respect to the parent column width, so the img-fluid class is necessary. These images nicely scale down to xs displays, but it does look a little cluttered on a small viewport. Consider Figure 2.17:

Apart from the rounded-circle and rounded classes, Bootstrap also offers classes for rounding per side: up, down, left, or right. For example, the rounded-top class rounded the top corners of an element. Similarly, the rounded-bottom class would round the element’s bottom corners by setting the border-bottom-right-radius and border-bottom-left-radius properties to 0.25 rem.
Let's apply the classes with the following in mind:
- The image for the Small category has its right corners rounded
- The image for the Medium category has its left corners rounded
- The image for the Large category has its bottom corners rounded
Observe the following code:
<div class="container">
<h1>Our Print Sizes</h1>
<div class="row">
<div class="col-sm-3">
<img src="images/small.jpg" class="img-fluid rounded-
right">
<h5>Small</h5>
...
</div>
<div class="col-sm-3">
<img src="images/medium.jpg" class="img-fluid rounded-
left">
<h5>Medium</h5>
...
</div>
<div class="col-sm-3">
<img src="images/large.jpg" class="img-fluid rounded-
bottom">
<h5>Large</h5>
...
</div>
<div class="col-sm-3">
<img src="images/extra-large.jpg" class="img-fluid">
<h5>Extra Large</h5>
...
</div>
</div>
</div>
- 嵌入式Linux系統(tǒng)開發(fā):基于Yocto Project
- Linux Shell編程從入門到精通(第2版)
- 深入理解eBPF與可觀測性
- Android物聯(lián)網(wǎng)開發(fā)細致入門與最佳實踐
- Linux內(nèi)核觀測技術(shù)BPF
- Red Hat Enterprise Linux 6.4網(wǎng)絡(luò)操作系統(tǒng)詳解
- 跟老男孩學(xué)Linux運維:Shell編程實戰(zhàn)
- Windows 7實戰(zhàn)從入門到精通
- Linux網(wǎng)絡(luò)操作系統(tǒng)項目教程(RHEL 7.4/CentOS 7.4)(第3版)(微課版)
- Linux內(nèi)核修煉之道
- Windows網(wǎng)絡(luò)編程(第2版)
- Windows 8完全自學(xué)手冊
- 計算機應(yīng)用基礎(chǔ)(Windows 7+Office 2010)
- Website Development with PyroCMS
- Responsive Web Design with AngularJS