我有一个网站写在核心php,我想添加阿拉伯语。因此,我必须动态地将LTR转换为RTL。但是我该怎么做呢?我是否必须更改所有的css代码,并为RTL重写它们,或者还有其他东西吗?我搜索了很多次,找到了rtlcss,但是我怎么才能轻松地实现它们呢?
发布于 2019-04-17 02:39:08
以下所有代码都是纯示例,将被缩短
index.html
<html>
<head>
<link rel="stylesheet" type="text/css" href="/css/main.min.css">
<!-- this should be included if the user's language is RTL -->
<link rel="stylesheet" type="text/css" href="/css/rtl.min.css">
</head>
<body></body>
</html>main.min.css
/* here goes all css codes that goes with all pages */
body {
padding-top: 50px;
}
div.tab-content {
padding-top: 20px;
}
.main-panel {
float: right;
}rtl.min.css
/* this will override the previous css rule */
.main-panel {
float: left;
}
body {
direction: rtl;
margin: 0;
}你也可以将它们连接到一个文件中,在你的php文件中,将类添加到body .rtl中,并在你的css文件中(当然是在最后)添加css规则,如下所示:
body.rtl {
direction: rtl;
}但是为了简化css文件,并且由于许多用户不会从RTL规则中受益,我建议使用第一个示例
发布于 2019-07-04 17:59:10
有一些在线转换器来转换基于ltr的css代码到基于rtl的css代码。然后我添加了不同的css为不同的用户选择。所以将会有两个css文件。
发布于 2019-09-08 12:06:33
我用enter link description here ltr to rtl转换器解决了这个问题。然后对来自数据库的不同逻辑添加了不同的css。让我举个例子,我在数据库中存储了一个值,direction = 'ltr'/'rtl‘。所以在我的前端,在header标签中,我根据方向值添加了不同的css。我希望这个逻辑能有所帮助。
https://stackoverflow.com/questions/55714230
复制相似问题