Skip to content

Commit 06b93b2

Browse files
author
Robert-Jan Bijl
committed
Better support for RTL languages
CSS changes to better support RTL languages. Most notable is the positioning of the arrow on the left side of the select2 for RTL
1 parent 52425f9 commit 06b93b2

1 file changed

Lines changed: 45 additions & 0 deletions

File tree

select2.css

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ Version: @@ver@@ Timestamp: @@timestamp@@
5656
background-image: linear-gradient(to top, #eee 0%, #fff 50%);
5757
}
5858

59+
html[dir="rtl"] .select2-container .select2-choice {
60+
padding: 0 8px 0 0;
61+
}
62+
5963
.select2-container.select2-drop-above .select2-choice {
6064
border-bottom-color: #aaa;
6165

@@ -84,6 +88,11 @@ Version: @@ver@@ Timestamp: @@timestamp@@
8488
width: auto;
8589
}
8690

91+
html[dir="rtl"] .select2-container .select2-choice > .select2-chosen {
92+
margin-left: 26px;
93+
margin-right: 0;
94+
}
95+
8796
.select2-container .select2-choice abbr {
8897
display: none;
8998
width: 12px;
@@ -196,13 +205,26 @@ Version: @@ver@@ Timestamp: @@timestamp@@
196205
background-image: linear-gradient(to top, #ccc 0%, #eee 60%);
197206
}
198207

208+
html[dir="rtl"] .select2-container .select2-choice .select2-arrow {
209+
left: 0;
210+
right: auto;
211+
212+
border-left: none;
213+
border-right: 1px solid #aaa;
214+
border-radius: 4px 0 0 4px;
215+
}
216+
199217
.select2-container .select2-choice .select2-arrow b {
200218
display: block;
201219
width: 100%;
202220
height: 100%;
203221
background: url('select2.png') no-repeat 0 1px;
204222
}
205223

224+
html[dir="rtl"] .select2-container .select2-choice .select2-arrow b {
225+
background-position: 2px 1px;
226+
}
227+
206228
.select2-search {
207229
display: inline-block;
208230
width: 100%;
@@ -241,6 +263,16 @@ Version: @@ver@@ Timestamp: @@timestamp@@
241263
background: url('select2.png') no-repeat 100% -22px, linear-gradient(to bottom, #fff 85%, #eee 99%) 0 0;
242264
}
243265

266+
html[dir="rtl"] .select2-search input {
267+
padding: 4px 5px 4px 20px;
268+
269+
background: #fff url('select2.png') no-repeat -37px -22px;
270+
background: url('select2.png') no-repeat -37px -22px, -webkit-gradient(linear, left bottom, left top, color-stop(0.85, #fff), color-stop(0.99, #eee));
271+
background: url('select2.png') no-repeat -37px -22px, -webkit-linear-gradient(center bottom, #fff 85%, #eee 99%);
272+
background: url('select2.png') no-repeat -37px -22px, -moz-linear-gradient(center bottom, #fff 85%, #eee 99%);
273+
background: url('select2.png') no-repeat -37px -22px, linear-gradient(to bottom, #fff 85%, #eee 99%) 0 0;
274+
}
275+
244276
.select2-drop.select2-drop-above .select2-search input {
245277
margin-top: 4px;
246278
}
@@ -295,10 +327,18 @@ Version: @@ver@@ Timestamp: @@timestamp@@
295327
border-left: none;
296328
filter: none;
297329
}
330+
html[dir="rtl"] .select2-dropdown-open .select2-choice .select2-arrow {
331+
border-right: none;
332+
}
333+
298334
.select2-dropdown-open .select2-choice .select2-arrow b {
299335
background-position: -18px 1px;
300336
}
301337

338+
html[dir="rtl"] .select2-dropdown-open .select2-choice .select2-arrow b {
339+
background-position: -16px 1px;
340+
}
341+
302342
.select2-hidden-accessible {
303343
border: 0;
304344
clip: rect(0 0 0 0);
@@ -321,6 +361,11 @@ Version: @@ver@@ Timestamp: @@timestamp@@
321361
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
322362
}
323363

364+
html[dir="rtl"] .select2-results {
365+
padding: 0 4px 0 0;
366+
margin: 4px 0 4px 4px;
367+
}
368+
324369
.select2-results ul.select2-result-sub {
325370
margin: 0;
326371
padding-left: 0;

0 commit comments

Comments
 (0)