小白教程
所有教程
关于
Search
172.69.6.142
172.69.6.142
参数设置
贡献
退出
操作
编辑
移动
保护
信息
历史
删除
查看“Bootstrap5 图像形状”的源代码
本页内容
上一节:
Bootstrap5_表格
下一节:
Bootstrap5_Jumbotron
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
{{DISPLAYTITLE:Bootstrap5 图像形状}}[[Category:Bootstrap 5 教程|8]] = Bootstrap5 图像形状 = == 圆角图片 == .rounded 类可以让图片显示圆角效果: <sample title="" desc="" lang="html" hererun="1"> <img src="cinqueterre.jpg" class="rounded" alt="Cinque Terre"> </sample> <run name=""> <!DOCTYPE html> <html> <head> <title>Bootstrap5 实例</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link href="https://cdn.staticfile.org/twitter-bootstrap/5.1.1/css/bootstrap.min.css" rel="stylesheet"> <script src="https://cdn.staticfile.org/twitter-bootstrap/5.1.1/js/bootstrap.bundle.min.js"></script> </head> <body> <div class="container mt-3"> <h2>圆角图片</h2> <p>.rounded 类可以让图片显示圆角效果:</p> <img src="http://static.xiaobai.wang/images/mix/cinqueterre.jpg" class="rounded" alt="Cinque Terre" width="304" height="236"> </div> </body> </html> </run> == 椭圆图片 == .rounded-circle 类可以设置椭圆形图片: <sample title="" desc="" lang="html" hererun="1"> <img src="cinqueterre.jpg" class="rounded-circle" alt="Cinque Terre"> </sample> <run name=""> <!DOCTYPE html> <html> <head> <title>Bootstrap5 实例</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link href="https://cdn.staticfile.org/twitter-bootstrap/5.1.1/css/bootstrap.min.css" rel="stylesheet"> <script src="https://cdn.staticfile.org/twitter-bootstrap/5.1.1/js/bootstrap.bundle.min.js"></script> </head> <body> <div class="container mt-3"> <h2>椭圆图片</h2> <p>.rounded-circle 类可以设置椭圆形图片:</p> <img src="http://static.xiaobai.wang/images/mix/cinqueterre.jpg" class="rounded-circle" alt="Cinque Terre"> </div> </body> </html> </run> == 缩略图 == .img-thumbnail 类用于设置图片缩略图(图片有边框): <sample title="" desc="" lang="html" hererun="1"> <img src="cinqueterre.jpg" class="img-thumbnail" alt="Cinque Terre"> </sample> <run name=""> <!DOCTYPE html> <html> <head> <title>Bootstrap5 实例</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link href="https://cdn.staticfile.org/twitter-bootstrap/5.1.1/css/bootstrap.min.css" rel="stylesheet"> <script src="https://cdn.staticfile.org/twitter-bootstrap/5.1.1/js/bootstrap.bundle.min.js"></script> </head> <body> <div class="container mt-3"> <h2>缩略图</h2> <p>.img-thumbnail 类用于设置图片缩略图(图片有边框):</p> <img src="cinqueterre.jpg" class="img-thumbnail" alt="Cinque Terre" width="304" height="236"> </div> </body> </html> </run> == 图片对齐方式 == 使用 .float-start 类来设置图片左对齐,使用 .float-end 类设置图片右对齐: <sample title="" desc="" lang="html" hererun="1"> <img src="paris.jpg" class="float-start"> <img src="cinqueterre.jpg" class="float-end"> </sample> <run name=""> <!DOCTYPE html> <html> <head> <title>Bootstrap5 实例</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link href="https://cdn.staticfile.org/twitter-bootstrap/5.1.1/css/bootstrap.min.css" rel="stylesheet"> <script src="https://cdn.staticfile.org/twitter-bootstrap/5.1.1/js/bootstrap.bundle.min.js"></script> </head> <body> <div class="container mt-3"> <h2>图片对齐方式</h2> <p>使用 .float-start 类来设置图片左对齐,使用 .float-end 类设置图片右对齐:</p> <img src="paris.jpg" class="float-start" alt="Paris" width="304" height="236"> <img src="paris.jpg" class="float-end" alt="Paris" width="304" height="236"> </div> </body> </html> </run> == 图片居中 == 使用 .mx-auto (margin:auto) 和 .d-block (display:block) 类来设置图片居中对齐: <sample title="" desc="" lang="html" hererun="1"> <img src="paris.jpg" class="mx-auto d-block"> </sample> <run name=""> <!DOCTYPE html> <html> <head> <title>Bootstrap5 实例</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link href="https://cdn.staticfile.org/twitter-bootstrap/5.1.1/css/bootstrap.min.css" rel="stylesheet"> <script src="https://cdn.staticfile.org/twitter-bootstrap/5.1.1/js/bootstrap.bundle.min.js"></script> </head> <body> <div class="container mt-3"> <h2>图片居中</h2> <p>使用 .mx-auto (margin:auto) 和 .d-block (display:block) 类来设置图片居中对齐:</p> <img src="paris.jpg" class="mx-auto d-block" style="width:50%"> </div> </body> </html> </run> == 响应式图片 == 图像有各种各样的尺寸,我们需要根据屏幕的大小自动适应。 我们可以通过在 <img> 标签中添加 .img-fluid 类来设置响应式图片。 .img-fluid 类设置了 max-width: 100%; 、 height: auto; : <sample title="" desc="" lang="html" hererun="1"> <img class="img-fluid" src="img_chania.jpg" alt="Chania"> </sample> <run name=""> <!DOCTYPE html> <html> <head> <title>Bootstrap5 实例</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link href="https://cdn.staticfile.org/twitter-bootstrap/5.1.1/css/bootstrap.min.css" rel="stylesheet"> <script src="https://cdn.staticfile.org/twitter-bootstrap/5.1.1/js/bootstrap.bundle.min.js"></script> </head> <body> <div class="container mt-3"> <h2>响应式图片</h2> <p>.img-fluid 类可以设置响应式图片,重置浏览器大小查看效果:</p> <img src="http://static.xiaobai.wang/images/mix/paris.jpg" class="img-fluid"> </div> </body> </html> </run>
返回至“
Bootstrap5 图像形状
”。
上一节:
Bootstrap5_表格
下一节:
Bootstrap5_Jumbotron