Bootstrap 5 图像
图像形状
圆角图片:

椭圆图片:

缩略图:

圆角图片
.rounded
类可以让图片显示圆角效果:
椭圆图片
.rounded-circle
类可以设置椭圆形图片:
缩略图
.img-thumbnail
类用于设置图片缩略图(图片有边框):
图片对齐方式
使用 .float-start
类来设置图片左对齐,使用 .float-end
类设置图片右对齐:


图片居中
使用 .mx-auto
(margin:auto) 和 .d-block
(display:block) 类来设置图片居中对齐:

响应式图片
图像有各种各样的尺寸,我们需要根据屏幕的大小自动适应。
我们可以通过在 <img>
标签中添加 .img-fluid
类来设置响应式图片。
.img-fluid
类设置了 max-width: 100%;
和 height: auto;
: