RTL
Phunzirani momwe mungathandizire kuthandizira zolemba kuchokera kumanja kupita kumanzere mu Bootstrap pamasanjidwe athu, zida, ndi zofunikira.
Dziwani bwino
Tikukulimbikitsani kuti mudziwe zambiri za Bootstrap powerenga patsamba lathu loyambira . Mukamaliza, pitilizani kuwerenga apa kuti muyambitse bwanji RTL.
Mwinanso mungafune kuwerenga pulojekiti ya RTLCSS , chifukwa imathandizira njira yathu ya RTL.
Zoyeserera
Mawonekedwe a RTL akadali oyesera ndipo mwina asintha malinga ndi mayankho a ogwiritsa ntchito. Kodi mwawonapo kanthu kapena muli ndi zomwe munganene? Tsegulani nkhani , tikufuna kudziwa zambiri.
HTML yofunika
Pali zofunikira ziwiri zolimba kuti mutsegule RTL mumasamba oyendetsedwa ndi Bootstrap.
- Khalani
dir="rtl"
pa<html>
chinthu. - Onjezani chinthu choyenera
lang
, mongalang="ar"
, pa<html>
chinthucho.
Kuchokera pamenepo, muyenera kuphatikiza mtundu wa RTL wa CSS yathu. Mwachitsanzo, nali masitayelo a CSS yathu yopangidwa ndi minified yokhala ndi RTL yoyatsidwa:
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.rtl.min.css" integrity="sha384-gXt9imSW0VcJVHezoNQsP+TNrjYXoGcrqBZJpry9zJt8PCQjobwmhMGaDHTASo9N" crossorigin="anonymous">
template yoyambira
Mutha kuwona zomwe zili pamwambapa zomwe zikuwonetsedwa mu template yosinthidwa ya RTL.
<!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-gXt9imSW0VcJVHezoNQsP+TNrjYXoGcrqBZJpry9zJt8PCQjobwmhMGaDHTASo9N" 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-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" 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-IQsoLXl5PILFhosVNubq5LC7Qb9DXgDA9i+tQ8Zj3iwWAwPtgFTxbJ8NT4GN1R8p" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js" integrity="sha384-cVKIPhGWiC2Al4u+LWgxfKTRIcfu0JTxR+EQDz/bgldoEyl4H0zUF0QKbrJ0EcQF" crossorigin="anonymous"></script>
-->
</body>
</html>
RTL zitsanzo
Yambani ndi chimodzi mwa zitsanzo zathu zingapo za RTL .
Njira
Njira yathu yopangira chithandizo cha RTL mu Bootstrap imabwera ndi zisankho ziwiri zofunika zomwe zimakhudza momwe timalembera ndikugwiritsa ntchito CSS yathu:
-
Choyamba, tinaganiza zomanga ndi polojekiti ya RTLCSS . Izi zimatipatsa zida zamphamvu zowongolera zosintha ndikuzichotsa mukamachoka ku LTR kupita ku RTL. Imatithandizanso kupanga mitundu iwiri ya Bootstrap kuchokera ku codebase imodzi.
-
Chachiwiri, tasinthanso magulu angapo owongolera kuti agwiritse ntchito njira zomveka. Ambiri ainu mudalumikizana kale ndi zinthu zomveka chifukwa cha zida zathu zosinthika - zimasintha mawonekedwe amayendedwe monga
left
ndikuthandiziraright
ndistart
.end
Izi zimapangitsa kuti mayina amkalasi ndi zikhalidwe zikhale zoyenera kwa LTR ndi RTL popanda kuwongolera kulikonse.
Mwachitsanzo, m'malo mwa .ml-3
, margin-left
gwiritsani ntchito .ms-3
.
Kugwira ntchito ndi RTL, kudzera mu gwero lathu la Sass kapena CSS yophatikizidwa, sikuyenera kukhala kosiyana kwambiri ndi LTR yathu yokhazikika.
Sinthani Mwamakonda Anu kuchokera kochokera
Zikafika pakusintha mwamakonda , njira yomwe mumakonda ndikutenga mwayi pazosintha, mamapu, ndi zosakaniza. Njirayi imagwira ntchito chimodzimodzi kwa RTL, ngakhale itasinthidwa kuchokera pamafayilo ophatikizidwa, chifukwa cha momwe RTLCSS imagwirira ntchito .
Mtengo wa RTL
Pogwiritsa ntchito RTLCSS value Directives , mutha kupanga zosintha kukhala mtengo wosiyana wa RTL. Mwachitsanzo, kuti muchepetse kulemera kwa $font-weight-bold
codebase yonse, mutha kugwiritsa ntchito /*rtl: {value}*/
mawu akuti:
$font-weight-bold: 700 #{/* rtl:600 */} !default;
Zomwe zingatulutse ku zotsatirazi kwa CSS yathu yokhazikika ndi RTL CSS:
/* bootstrap.css */
dt {
font-weight: 700 /* rtl:600 */;
}
/* bootstrap.rtl.css */
dt {
font-weight: 600;
}
Mitundu ina ya zilembo
Ngati mukugwiritsa ntchito zilembo zachilatini, dziwani kuti si zilembo zonse zomwe zimagwirizana ndi zilembo zomwe si zachilatini. Kuti musinthe kuchoka ku Pan-European kupita kubanja lachiarabu, mungafunike kugwiritsa ntchito /*rtl:insert: {value}*/
font yanu kuti musinthe mayina amitundu yamafonti.
Mwachitsanzo, kusintha kuchokera Helvetica Neue Webfont
ku LTR kupita Helvetica Neue Arabic
ku RTL, nambala yanu ya Sass imawoneka motere:
$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 ndi RTL nthawi yomweyo
Mukufuna zonse za LTR ndi RTL patsamba lomwelo? Chifukwa cha RTLCSS String Maps , izi ndizowongoka kwambiri. Manga @import
s anu ndi kalasi, ndikukhazikitsa lamulo lakusintha dzina la 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*/
Pambuyo kuthamanga Sass ndiye RTLCSS, aliyense kusankha mu CSS owona adzakhala prepended ndi .ltr
, ndi .rtl
RTL owona. Tsopano mutha kugwiritsa ntchito mafayilo onse patsamba lomwelo, ndikungogwiritsa ntchito .ltr
kapena .rtl
pazigawo zanu kuti mugwiritse ntchito njira imodzi kapena ina.
Milandu ya m'mphepete ndi malire odziwika
Ngakhale njira iyi ndiyomveka, chonde samalani izi:
- Mukasintha
.ltr
ndi.rtl
, onetsetsani kuti mwawonjezeradir
ndikuwonetsalang
molingana. - Kutsegula mafayilo onsewa kumatha kukhala vuto lenileni: ganizirani kukhathamiritsa , ndipo mwina yesani kutsitsa imodzi mwamafayilowo mosasinthasintha .
- Masitayilo a nesting motere alepheretsa
form-validation-state()
mixin yathu kuti isagwire ntchito monga momwe timafunira, chifukwa chake imafunika kuti musinthe nokha. Onani #31223 .
Mkate wa mkate
Cholekanitsa mkate ndiye vuto lokhalo lomwe limafunikira mtundu wake watsopano - womwe ndi $breadcrumb-divider-flipped
-kusasintha mpaka $breadcrumb-divider
.