RTL
Sua sɛnea wobɛma mmoa ama nsɛm a efi nifa so kɔ benkum wɔ Bootstrap mu wɔ yɛn nhyehyɛe, nneɛma a ɛwom, ne mfaso horow no nyinaa mu.
Hu ade yiye
Yɛhyɛ nyansa sɛ di kan hu Bootstrap yiye denam yɛn Getting Started Introduction krataafa no a wobɛkenkan no so . Sɛ wutu mmirika fa mu wie a, kɔ so kenkan wɔ ha ma sɛnea wobɛma RTL ayɛ adwuma.
Ebia wobɛpɛ nso sɛ wokenkan kɔ soro wɔ RTLCSS adwuma no ho , efisɛ ɛma yɛn kwan a yɛfa so yɛ RTL no tumi.
Nneɛma a wɔde sɔ hwɛ
RTL afã no da so ara yɛ sɔhwɛ na ebia ɛbɛdannan sɛnea wɔn a wɔde di dwuma no nsɛm te. Woahu biribi anaasɛ wowɔ nkɔso bi a wopɛ sɛ wohyɛ ho nyansa? Open an issue , yɛn ani begye ho sɛ yebenya wo nhumu.
HTML a wɔhwehwɛ
Ahwehwɛdeɛ mmienu a ɛyɛ katee wɔ hɔ a ɛbɛma RTL ayɛ adwuma wɔ nkratafa a Bootstrap-powered no mu.
- Fa
dir="rtl"
si<html>
element no so. - Fa
lang
su a ɛfata, te sɛlang="ar"
, ka<html>
element no so.
Efi hɔ no, ɛho behia sɛ wode yɛn CSS no RTL nkyerɛase bi ka ho. Sɛ nhwɛso no, yɛn CSS a wɔaboaboa ano na wɔayɛ no ketewaa a RTL ayɛ adwuma no ho stylesheet ni:
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.rtl.min.css" integrity="sha384-+qdLaIRZfNu4cVPK/PxJJEy0B0f3Ugv8i482AKY7gwXwhaCroABd086ybrVKTa0q" crossorigin="anonymous">
Starter nsusuwso
Wubetumi ahu atifi hɔ ahwehwɛde ahorow a ɛda adi wɔ RTL mfiase nsusuwso a wɔayɛ no foforo yi mu.
<!doctype html>
<html lang="ar" dir="rtl">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.rtl.min.css" integrity="sha384-+qdLaIRZfNu4cVPK/PxJJEy0B0f3Ugv8i482AKY7gwXwhaCroABd086ybrVKTa0q" crossorigin="anonymous">
<title>مرحبا بالعالم!</title>
</head>
<body>
<h1>مرحبا بالعالم!</h1>
<!-- Optional JavaScript; choose one of the two! -->
<!-- Option 1: Bootstrap Bundle with Popper -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
<!-- Option 2: Separate Popper and Bootstrap JS -->
<!--
<script src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js" integrity="sha384-7+zCNj/IqJ95wo16oMtfsKbZ9ccEh31eOz1HGyDuCQ6wgnyJNSYdrPa03rtR1zdB" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js" integrity="sha384-QJHtvGhmr9XOIpI6YVutG+2QOK9T+ZnN4kzFN1RtK3zEFEIsxhlmWl5/YESvpZ13" crossorigin="anonymous"></script>
-->
</body>
</html>
RTL nhwɛso ahorow
Fa yɛn RTL nhwɛso ahorow pii no mu biako fi ase .
Kwan
Yɛn kwan a yɛfa so kyekye RTL mmoa kɔ Bootstrap mu no de gyinaesi ahorow abien a ɛho hia a ɛka sɛnea yɛkyerɛw na yɛde yɛn CSS di dwuma no ba:
-
Nea edi kan no, yesii gyinae sɛ yɛde RTLCSS adwuma no besi. Wei ma yɛn nneɛma bi a tumi wom a yɛde hwɛ nsakraeɛ ne overrides so berɛ a yɛrefiri LTR akɔ RTL. Ɛsan nso ma yɛtumi yɛ Bootstrap nkyerɛaseɛ mmienu firi codebase baako mu.
-
Nea ɛto so abien, yɛasesa akwankyerɛ adesua ahorow kakraa bi din de afa logical properties kwan so. Mo mu dodow no ara ne logical properties adi nkitaho dedaw esiane yɛn flex utilities nti —wɔsesa direction properties te sɛ
left
neright
in favorstart
neend
. Ɛno ma adesuakuw din ne gyinapɛn ahorow no fata ma LTR ne RTL a enni ɔsoro.
Sɛ nhwɛso no, sɛ́ anka wode .ml-3
for bedi dwuma no margin-left
, fa .ms-3
.
Adwuma a ɛne RTL, nam yɛn fibea Sass anaa CSS a wɔaboaboa ano no, ɛnsɛ sɛ ɛyɛ soronko kɛse wɔ yɛn default LTR no ho de, nanso.
Yɛ wo ho sɛnea wopɛ fi fibea
Sɛ ɛba customization , ɔkwan a wɔpɛ ne sɛ wode variables, maps, ne mixins bedi dwuma. Saa kwan yi yɛ adwuma saa ara ma RTL, sɛ mpo ɛyɛ post-processed fi fael ahorow a wɔaboaboa ano no mu a, ɛnam sɛnea RTLCSS yɛ adwuma nti .
RTL gyinapɛn ahorow a wɔahyɛ da ayɛ
Sɛ wode RTLCSS botae akwankyerɛ di dwuma a , wubetumi ama nsakrae a ɛba no ayɛ botae soronko ama RTL. Sɛ nhwɛso no, sɛ wopɛ sɛ wotew emu duru so ma $font-weight-bold
wɔ codebase no nyinaa mu a, wubetumi de /*rtl: {value}*/
syntax no adi dwuma:
$font-weight-bold: 700 #{/* rtl:600 */} !default;
Nea ɛbɛba no akɔ nea edidi so yi so ama yɛn default CSS ne RTL CSS:
/* bootstrap.css */
dt {
font-weight: 700 /* rtl:600 */;
}
/* bootstrap.rtl.css */
dt {
font-weight: 600;
}
Font stack foforo a wɔde di dwuma
Sɛ ɛba sɛ wode nkyerɛwde a wɔahyɛ da ayɛ redi dwuma a, hu sɛ ɛnyɛ nkyerɛwde nyinaa na ɛboa nkyerɛwde a ɛnyɛ Latin de no. Sɛ wopɛ sɛ wodan fi Pan-European kɔ Arabic abusua mu a, ebia ɛho behia sɛ wode di dwuma /*rtl:insert: {value}*/
wɔ wo font stack no mu de sesa font mmusua din.
Sɛ nhwɛso no, sɛ wopɛ sɛ wodan fi Helvetica Neue Webfont
for LTR kɔ Helvetica Neue Arabic
for RTL a, wo Sass code no te sɛ eyi:
$font-family-sans-serif:
Helvetica Neue #{"/* rtl:insert:Arabic */"},
// Cross-platform generic font family (default user interface font)
system-ui,
// Safari for macOS and iOS (San Francisco)
-apple-system,
// Chrome < 56 for macOS (San Francisco)
BlinkMacSystemFont,
// Windows
"Segoe UI",
// Android
Roboto,
// Basic web fallback
Arial,
// Linux
"Noto Sans",
// Sans serif fallback
sans-serif,
// Emoji fonts
"Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji" !default;
LTR ne RTL bere koro mu
Wo hia LTR ne RTL nyinaa wɔ kratafa koro no ara so? Aseda nka RTLCSS String Maps , eyi yɛ fɛ tẽẽ. Fa @import
adesua bi kyekyere wo s no, na fa amanne din foforo mmara ma RTLCSS:
/* rtl:begin:options: {
"autoRename": true,
"stringMap":[ {
"name": "ltr-rtl",
"priority": 100,
"search": ["ltr"],
"replace": ["rtl"],
"options": {
"scope": "*",
"ignoreCase": false
}
} ]
} */
.ltr {
@import "../node_modules/bootstrap/scss/bootstrap";
}
/*rtl:end:options*/
Sɛ wotu Sass afei RTLCSS wie a, paw biara a ɛwɔ wo CSS fael ahorow no mu no bedi kan de .ltr
, ne .rtl
ama RTL fael ahorow no. Seesei woatumi de fael abien no nyinaa adi dwuma wɔ kratafa koro no ara so, na wode .ltr
anaa .rtl
wo components wrappers no di dwuma ara kwa de akwankyerɛ biako anaa foforo no adi dwuma.
Edge nsɛm ne anohyeto ahorow a wonim
Bere a ntease wɔ ɔkwan yi so no, yɛsrɛ sɛ hwɛ nea edidi so yi yiye:
- Sɛ woresakra
.ltr
ne.rtl
, hwɛ hu sɛ wode bɛka hodir
nelang
su ahorow sɛnea ɛfata. - Fael abien no nyinaa a wode bɛhyɛ mu no betumi ayɛ adwumayɛ mu ɔhaw ankasa: susuw optimization bi ho , na ebia bɔ mmɔden sɛ wode saa fael no mu biako bɛhyɛ mu asynchronously .
- Nesting styles saa kwan yi so no besiw yɛn
form-validation-state()
mixin no kwan sɛ ɛbɛyɛ adwuma sɛnea wɔahyɛ da ayɛ no, enti ɛhwehwɛ sɛ wo tweak no kakra wɔ w’ankasa wo ho. Hwɛ #31223 .
Abodoo a wɔayam no aduru no
Breadcrumb separator no nkutoo ne asɛm a ɛhwehwɛ sɛ n’ankasa nsakrae foforo koraa— a ɛne $breadcrumb-divider-flipped
—defaulting to $breadcrumb-divider
.