Ratios

      Use generated pseudo elements to make an element maintain the aspect ratio of your choosing. Perfect for responsively handling video or slideshow embeds based on the width of the parent.

      About

      Use the ratio helper to manage the aspect ratios of external content like <iframe>s, <embed>s, <video>s, and <object>s. These helpers also can be used on any standard HTML child element (e.g., a <div> or <img>). Styles are applied from the parent .ratio class directly to the child.

      Aspect ratios are declared in a Sass map and included in each class via CSS variable, which also allows custom aspect ratios.

      Pro-Tip! You don’t need frameborder="0" on your <iframe>s as we override that for you in Reboot.

      Example

      Wrap any embed, like an <iframe>, in a parent element with .ratio and an aspect ratio class. The immediate child element is automatically sized thanks to our universal selector .ratio > *.

      <div class="ratio ratio-16x9">
        <iframe src="https://www.youtube.com/embed/zpOULjyy-n8?rel=0" title="YouTube video" allowfullscreen></iframe>
      </div>

      Aspect ratios

      Aspect ratios can be customized with modifier classes. By default the following ratio classes are provided:

      1x1
      4x3
      16x9
      21x9
      <div class="ratio ratio-1x1">
        <div>1x1</div>
      </div>
      <div class="ratio ratio-4x3">
        <div>4x3</div>
      </div>
      <div class="ratio ratio-16x9">
        <div>16x9</div>
      </div>
      <div class="ratio ratio-21x9">
        <div>21x9</div>
      </div>

      Custom ratios

      Each .ratio-* class includes a CSS custom property (or CSS variable) in the selector. You can override this CSS variable to create custom aspect ratios on the fly with some quick math on your part.

      For example, to create a 2x1 aspect ratio, set --bs-aspect-ratio: 50% on the .ratio.

      2x1
      <div class="ratio" style="--bs-aspect-ratio: 50%;">
        <div>2x1</div>
      </div>

      This CSS variable makes it easy to modify the aspect ratio across breakpoints. The following is 4x3 to start, but changes to a custom 2x1 at the medium breakpoint.

      .ratio-4x3 {
        @include media-breakpoint-up(md) {
          --bs-aspect-ratio: 50%; // 2x1
        }
      }
      
      4x3, then 2x1
      <div class="ratio ratio-4x3">
        <div>4x3, then 2x1</div>
      </div>

      Sass map

      Within _variables.scss, you can change the aspect ratios you want to use. Here’s our default $ratio-aspect-ratios map. Modify the map as you like and recompile your Sass to put them to use.

      $aspect-ratios: (
        "1x1": 100%,
        "4x3": calc(3 / 4 * 100%),
        "16x9": calc(9 / 16 * 100%),
        "21x9": calc(9 / 21 * 100%)
      );
      
      返回頂部
      主站蜘蛛池模板: 国产一区二区三区小说| 亚洲大尺度无码无码专线一区| 无码人妻一区二区三区精品视频 | 国精产品一区一区三区| 国产精品亚洲综合一区| 国产亚洲一区二区在线观看| 久久伊人精品一区二区三区 | 成人在线视频一区| 中文字幕日韩一区二区三区不 | 一本大道在线无码一区| 波多野结衣一区二区三区高清av| 亚洲AV无码一区二区三区国产| 精品一区二区三区中文字幕| 精品国产一区二区三区无码| 国产在线一区视频| 无码成人一区二区| 人成精品视频三区二区一区| 久久精品中文字幕一区| 亚洲美女视频一区二区三区 | 亚洲成人一区二区| 久久er99热精品一区二区| 怡红院美国分院一区二区| 国产一区二区三区在线影院| 亚洲一区二区三区四区视频 | 91精品一区二区综合在线| 动漫精品一区二区三区3d| 亚洲成在人天堂一区二区| 国产精品成人一区无码| 日韩人妻精品一区二区三区视频| 美女视频黄a视频全免费网站一区| 美女啪啪一区二区三区| 国产一区二区三区在线看片 | 美日韩一区二区三区| 久久精品视频一区二区三区| 精彩视频一区二区| 午夜一区二区免费视频| 久久se精品一区精品二区国产| 亚洲日韩精品一区二区三区无码| 国产精品xxxx国产喷水亚洲国产精品无码久久一区 | 久久久久人妻一区二区三区vr| 国偷自产一区二区免费视频|