Menu
×
   ❮     
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS R TYPESCRIPT ANGULAR GIT POSTGRESQL MONGODB ASP AI GO KOTLIN SASS VUE DSA GEN AI SCIPY AWS CYBERSECURITY DATA SCIENCE
     ❯   

Bootstrap 4 图片


Bootstrap 4 图片形状

圆角

Paris

圆形

NYC

缩略图

San Fran

圆角

使用 .rounded 类为图片添加圆角

示例

<img src="cinqueterre.jpg" class="rounded" alt="Cinque Terre">
试一试 »

圆形

使用 .rounded-circle 类将图片形状设置为圆形

示例

<img src="cinqueterre.jpg" class="rounded-circle" alt="Cinque Terre">
试一试 »

缩略图

使用 .img-thumbnail 类将图片形状设置为缩略图(带边框)

示例

<img src="cinqueterre.jpg" class="img-thumbnail" alt="Cinque Terre">
试一试 »


对齐图片

使用 .float-right 类将图片浮动到右侧,或者使用 .float-left 类将其浮动到左侧

示例

<img src="paris.jpg" class="float-left">
<img src="paris.jpg" class="float-right">
试一试 »

居中图片

通过向图片添加实用程序类 .mx-auto (margin:auto) 和 .d-block (display:block) 来居中图片

示例

<img src="paris.jpg" class="mx-auto d-block">
试一试 »

响应式图片

图片有各种尺寸,屏幕也有各种尺寸。响应式图片会自动调整以适应屏幕大小。

通过向 <img> 标签添加 .img-fluid 类来创建响应式图片。然后,图片将根据父元素的大小进行完美缩放。

.img-fluid 类会向图片应用 max-width: 100%;height: auto;

示例

<img class="img-fluid" src="img_chania.jpg" alt="Chania">
试一试 »

×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
[email protected]

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
[email protected]

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie and privacy policy.

Copyright 1999-2024 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.