我有一个用核心 php 编写的网站,我想添加阿拉伯语。所以我必须动态地将 LTR 转换为 RTL。但是我该怎么做呢?我是否必须更改所有 css 代码并为 RTL 重新编写它们,还是还有其他任何东西?我搜索了很多并找到了 rtlcss,但我怎样才能轻松实现它们?
最佳答案
以下所有代码均为纯示例,将被缩短
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>
主.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 文件中将类添加到正文 .rtl
并在您的 css 文件中(当然在最后)添加 css 规则,例如:
body.rtl {
direction: rtl;
}
但为了更轻的 css 文件,并且由于许多用户不会从 RTL 规则中受益,我建议使用第一个示例
关于php - 在核心 php 元素中动态地从 LTR 到 RTL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55714230/