embed-responsive

bootstrap5.css

bootstrap5.css
.embed-responsive {
  /* アスペクト比を持つ親要素に iframe のような埋め込みをラップします */
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  overflow: hidden;
}
bootstrap5.css
.embed-responsive::before {
  display: block;
  content: "";
}
bootstrap5.css
.embed-responsive .embed-responsive-item,
.embed-responsive iframe,
.embed-responsive embed,
.embed-responsive object,
.embed-responsive video {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0;
}
bootstrap5.css
.embed-responsive-21by9::before {
  padding-top: 42.857143%;
}
bootstrap5.css
.embed-responsive-16by9::before {
  padding-top: 56.25%;
}
bootstrap5.css
.embed-responsive-4by3::before {
  padding-top: 75%;
}
bootstrap5.css
.embed-responsive-1by1::before {
  padding-top: 100%;
}

html bootstrap5 Sample

Embed埋め込み/アスペクト比16:9:embed-responsive


  <!-- 大きさが自動調整される -->
  <!-- アスペクト比を持つ親要素に iframe のような埋め込みをラップします -->
  <div class="embed-responsive embed-responsive-16by9">
    <iframe class="embed-responsive-item" src="https://www.youtube.com/embed/SGqg_ZzThDU?rel=0"
      allowfullscreen></iframe>
  </div>