Ratios
Shandisa pseudo zvinhu zvakagadzirwa kugadzira chinhu kuchengetedza chikamu chesarudzo yako. Yakakwana yekubata zvine mutsindo vhidhiyo kana masiraidhi embeds zvichienderana nehupamhi hwemubereki.
About
Shandisa reshiyo mubatsiri kutonga mareshiyo ezvekunze senge <iframe>
s, <embed>
s, <video>
s, uye <object>
s. Ava vabatsiri zvakare vanogona kushandiswa pane chero yakajairwa HTML mwana chinhu (semuenzaniso, a <div>
kana <img>
). Zvitaera zvinoiswa kubva .ratio
kukirasi yevabereki zvakananga kumwana.
Aspect ratios inoziviswa mumepu yeSass uye inosanganisirwa mukirasi yega yega kuburikidza neCSS kusiyanisa, iyo inobvumirawo tsika yemaitiro ratios .
Muenzaniso
Putira chero embed, senge <iframe>
, mune chinhu chemubereki chine .ratio
uye chikamu chechiyero kirasi. Chinhu chemwana chiriporipo chinozvimisikidza saizi yekutenda kune yedu yepasirese yekusarudza .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 inogona kugadziridzwa ine modifier makirasi. Nekusagadzika makirasi eyero anotevera anopiwa:
<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
Kirasi yega .ratio-*
yega inosanganisira CSS tsika pfuma (kana CSS kushanduka) mune yekusarudza. Iwe unogona kupfuudza iyi CSS chinja kuti ugadzire yakajairika mareshiyo panhunzi uine imwe inokurumidza math padivi pako.
Semuyenzaniso, kugadzira 2x1 aspect ratio, set --bs-aspect-ratio: 50%
on the .ratio
.
<div class="ratio" style="--bs-aspect-ratio: 50%;">
<div>2x1</div>
</div>
Iyi CSS inosiyana inoita kuti zvive nyore kugadzirisa chikamu chechiyero pane mabreakpoints. Izvi zvinotevera 4x3 kutanga, asi kuchinja kune tsika 2x1 panguva yepakati breakpoint.
.ratio-4x3 {
@include media-breakpoint-up(md) {
--bs-aspect-ratio: 50%; // 2x1
}
}
<div class="ratio ratio-4x3">
<div>4x3, then 2x1</div>
</div>
Sass mepu
Mukati _variables.scss
me, unogona kushandura mareshiyo aunoda kushandisa. Heino $ratio-aspect-ratios
mepu yedu yemazuva ese. Shandura mepu sezvaunoda uye unganidzazve Sass yako kuti uishandise.
$aspect-ratios: (
"1x1": 100%,
"4x3": calc(3 / 4 * 100%),
"16x9": calc(9 / 16 * 100%),
"21x9": calc(9 / 21 * 100%)
);