简体   繁体   English

当表格中RTL和LTR之间的方向改变时,右向或左向填充问题

[英]Padding-Right or Padding-Left problem when direction change between RTL and LTR in a table

I'm developing a project in two languages (RTL and LTR) so when I design my tables some TDs must have right or left padding and I when I changes page direction to other, left padding means right and vies-versa and it is my problem because I shoud design my table once for RTl and once for LTR. 我正在用两种语言(RTL和LTR)开发一个项目,所以当我设计表时,某些TD必须具有右或左填充,而当我将页面方向更改为其他方向时,左填充意味着右移,反之亦然,这是我的问题是因为我应该为RTl和LTR设计表一次。

My problem: 我的问题:

LTR                  RTL

| | Hello| 您好| ----> | ----> | سلام| سلام|

that correct design: 正确的设计:

| | Hello| 您好| ----> |سلام | ----> |سلام|

Thanks 谢谢

If I understand the question correctly, I think you have two options. 如果我正确理解了这个问题,我认为您有两种选择。

One. 一。 create classes for specific directional text and style accordingly. 为特定的定向文本和样式创建类。 So 所以

<td class="rtl"></td>

and the css 和CSS

td.rtl{
    direction:rtl;
    padding-left:20px;  //OR WHATEVER
}

And then the opposite for ltr 然后将另一为ltr

Two. 二。 set the padding one way. 以一种方式设置填充。 Then use jQuery to detect the direction and adjust accordingly. 然后使用jQuery检测方向并进行相应调整。

So something like 所以像

$('td').each(function(){
    if($(this).css('direction') == 'rtl'){
        $(this).css({'padding-left':'//whatver','padding-right':'0'});
    }
}); 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM