php - 在核心 php 元素中动态地从 LTR 到 RTL

标签 php html css

我有一个用核心 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/

相关文章:

html - 如何去除css文件中重复的id

php - YII - BOOTSTRAP 配置错误?

html - 去除覆盖4列产品的白色背景

javascript - Bootstrap 菜单链接不可点击

php - 我有一个数组,但现在如何插入 csv 值 php mysql

php - 使用 PHP 在每个月的 HTML 表中显示日期

HTML,CSS : How to cause a div be presented on top of other divs

php - Ajax 回复 javascript 无法进行验证

php - 加入 MySQL 和关系表错误

css - 无法转换或动画 CSS 剪辑路径