我有许多为从左到右的网站制作的 CSS 文件
我想创建一个 php 函数,可以将 LTR 属性和值转换为它们的 RTL 对应项
我之所以要这样做是因为该网站始终处于开发阶段,并且它有数十个页面和 css 文件,并且很难跟踪所有这些文件
这个功能的目的是自动转换CSS文件,这样可以更容易地制作网站的RTL版本
例如:
// This is the content of the css file:
$content = '
html, body {
direction: ltr;
}
#element1 {
padding: 1px 2px 3px 4px;
margin-right: 3em;
background-position: 5% 80%;
background-image: url(image.png);
cursor: ne-resize;
text-align: left; /* 1 */
}
#element2 {
background: url(image.gif) 5% 80%;
text-align: right; /* 2 */
border-left: 1px solid #000;
}
';
$content = convertCSStoRTL($content);
// The output - This is what i want it to become after the function is applied to the content of the css file:
$content = '
html, body {
direction: rtl;
}
#element1 {
padding: 1px 4px 3px 2px;
margin-left: 3em;
background-position: 95% 80%;
background-image: url(image.png);
cursor: nw-resize;
text-align: right; /* 1 */
}
#element2 {
background: url(image.gif) 95% 80%;
text-align: left; /* 2 */
border-right: 1px solid #000;
}
';
我怎样才能在 PHP 中做到这一点(以最简单的方式)?