Bootstrap obrázky


Bootstrap obrazové tvary

Zaoblené rohy:

Pět zemí

Kruh:

Pět zemí

miniatura:

Pět zemí

Zaoblené rohy

Třída .img-roundedpřidá do obrázku zaoblené rohy (IE8 nepodporuje zaoblené rohy):

Příklad

<img src="cinqueterre.jpg" class="img-rounded" alt="Cinque Terre">

Kruh

Třída .img-circletvaruje obrázek do kruhu (IE8 nepodporuje zaoblené rohy):

Příklad

<img src="cinqueterre.jpg" class="img-circle" alt="Cinque Terre">

Náhled

Třída .img-thumbnailtvaruje obrázek do miniatury:

Příklad

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


Responzivní obrázky

Obrázky jsou ve všech velikostech. Stejně tak obrazovky. Responzivní obrázky se automaticky přizpůsobí velikosti obrazovky.

Vytvořte responzivní obrázky přidáním .img-responsivetřídy ke <img>značce. Obrázek se pak pěkně změní na nadřazený prvek.

Třída .img-responsiveplatí display: block;a max-width: 100%;a height: auto;pro obrázek:

Příklad

<img class="img-responsive" src="img_chania.jpg" alt="Chania">

Galerie Obrázků

Můžete také použít mřížkový systém Bootstrapu ve spojení s .thumbnailtřídou k vytvoření galerie obrázků.

Poznámka: Více o systému mřížky se dozvíte později v tomto tutoriálu (jak vytvořit rozložení s různým počtem sloupců).

Příklad

 <div class="row">
  <div class="col-md-4">
    <div class="thumbnail">
      <a href="/w3images/lights.jpg">
        <img src="/w3images/lights.jpg" alt="Lights" style="width:100%">
        <div class="caption">
          <p>Lorem ipsum...</p>
        </div>
      </a>
    </div>
  </div>
  <div class="col-md-4">
    <div class="thumbnail">
      <a href="/w3images/nature.jpg">
        <img src="/w3images/nature.jpg" alt="Nature" style="width:100%">
        <div class="caption">
          <p>Lorem ipsum...</p>
        </div>
      </a>
    </div>
  </div>
  <div class="col-md-4">
    <div class="thumbnail">
      <a href="/w3images/fjords.jpg">
        <img src="/w3images/fjords.jpg" alt="Fjords" style="width:100%">
        <div class="caption">
          <p>Lorem ipsum...</p>
        </div>
      </a>
    </div>
  </div>
</div>

Responzivní vložení

Nechte také videa nebo prezentace správně škálovat na jakémkoli zařízení.

Třídy lze použít přímo na prvky <iframe>, <embed>, <video> a <object>.

The following example creates a responsive video by adding an .embed-responsive-item class to an <iframe> tag (the video will then scale nicely to the parent element). The containing <div> defines the aspect ratio of the video:

Example

<div class="embed-responsive embed-responsive-16by9">
  <iframe class="embed-responsive-item" src="..."></iframe>
</div>

What is aspect ratio?

The aspect ratio of an image describes the proportional relationship between its width and its height. Two common video aspect ratios are 4:3 (the universal video format of the 20th century), and 16:9 (universal for HD television and European digital television).

You can choose between two aspect ratio classes:

<!-- 16:9 aspect ratio -->
<div class="embed-responsive embed-responsive-16by9">
  <iframe class="embed-responsive-item" src="..."></iframe>
</div>

<!-- 4:3 aspect ratio -->
<div class="embed-responsive embed-responsive-4by3">
  <iframe class="embed-responsive-item" src="..."></iframe>
</div>

Test Yourself With Exercises

Exercise:

Use a Bootstrap class to shape the image as a circle.

<img src="img_chania.jpg" alt="Chania" class=""> 


Complete Bootstrap Image Reference

For a complete reference of all image classes, go to our complete Bootstrap Image Reference.