官术网_书友最值得收藏!

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:

Figure 2.16: Applying Bootstrap's image modi?ers: rounded, rounded-circle, and img-thumbnail (example15.html)

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:

Figure 2.17: Dealing with smaller viewports by utilizing Bootstrap's responsive utilities

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>
主站蜘蛛池模板: 甘南县| 凤山县| 普定县| 襄垣县| 军事| 泾阳县| 城固县| 荥经县| 会理县| 修文县| 马鞍山市| 右玉县| 叙永县| 历史| 黄冈市| 北票市| 呈贡县| 贵港市| 涞源县| 武陟县| 朝阳区| 肥城市| 额敏县| 丹江口市| 蕉岭县| 游戏| 南通市| 彰化市| 邹平县| 巴东县| 昌平区| 阜平县| 静安区| 徐州市| 梓潼县| 黄石市| 咸阳市| 阳原县| 乃东县| 宜川县| 道真|