ข้ามไปที่เนื้อหาหลัก ข้ามไปที่การนำทางเอกสาร
Check
in English

รูปภาพ

เอกสารประกอบและตัวอย่างสำหรับการเลือกรูปภาพให้เป็นพฤติกรรมที่ตอบสนอง (ดังนั้นจึงไม่มีความกว้างกว่าระดับบนสุด) และเพิ่มสไตล์ที่มีน้ำหนักเบาให้กับพวกเขา—ทั้งหมดผ่านคลาส

ภาพที่ตอบสนอง

รูปภาพใน Bootstrap นั้นตอบสนองด้วย.img-fluid. สิ่งนี้นำไปใช้max-width: 100%;และheight: auto;กับรูปภาพเพื่อปรับขนาดด้วยความกว้างพาเรนต์

Placeholder Responsive image
html
<img src="..." class="img-fluid" alt="...">

ภาพขนาดย่อ

นอกจากยูทิลิตี้รัศมีเส้นขอบ ของเรา แล้ว คุณสามารถใช้.img-thumbnailเพื่อให้รูปภาพมีลักษณะเป็นขอบโค้งมน 1px

A generic square placeholder image with a white border around it, making it resemble a photograph taken with an old instant camera 200x200
html
<img src="..." class="img-thumbnail" alt="...">

การจัดแนวภาพ

จัดแนวรูปภาพกับคลาส float ตัวช่วยหรือ คลาส การจัดตำแหน่งข้อความ blockภาพระดับสามารถจัดกึ่งกลางโดยใช้ คลาส ยู.mx-auto ทิลิ ตี้ระยะขอบ

Placeholder 200x200 Placeholder 200x200
html
<img src="..." class="rounded float-start" alt="...">
<img src="..." class="rounded float-end" alt="...">
Placeholder 200x200
html
<img src="..." class="rounded mx-auto d-block" alt="...">
Placeholder 200x200
html
<div class="text-center">
  <img src="..." class="rounded" alt="...">
</div>

รูปภาพ

หากคุณกำลังใช้<picture>องค์ประกอบเพื่อระบุ<source>องค์ประกอบหลายรายการสำหรับเฉพาะ<img>ตรวจสอบให้แน่ใจว่าได้เพิ่ม.img-*คลาสลง ในแท็ก <img>และไม่ใช่ใน<picture>แท็ก

<picture>
  <source srcset="..." type="image/svg+xml">
  <img src="..." class="img-fluid img-thumbnail" alt="...">
</picture>

ซาส

ตัวแปร

มีตัวแปรสำหรับภาพขนาดย่อ

$thumbnail-padding:                 .25rem;
$thumbnail-bg:                      $body-bg;
$thumbnail-border-width:            $border-width;
$thumbnail-border-color:            var(--#{$prefix}border-color);
$thumbnail-border-radius:           $border-radius;
$thumbnail-box-shadow:              $box-shadow-sm;