【发布时间】:2013-07-09 04:19:39
【问题描述】:
一段时间以来,我在处理一个大型网站时遇到了问题。 主要问题是我们的网站提供两种语言:英文和中文。 中文网站也来自不同的域:domain.com 和 domain.com.cn
这给我们所有的 CSS 工作带来了一些问题,主要是字体,另一件事是域,因为图像是从我们的 CDN 提供的,我们必须将绝对链接放入我们的 CSS,但这也意味着我们必须更改它对于我们的中文网站
body.en .title { background: url(http://media.domain.com/title.png); }
body.cn .title { background: url(http://media.domain.com.cn/title.png); }
字体也是如此,我们英文版使用的字体不支持汉字,所以我们为汉字使用不同的字体
body.en .title { font-family: "Our English font" }
body.cn .title { font-family: "Our Chinese font" }
我现在想知道 SASS 是否可以帮助解决这个问题,目前我只有一个不同的文件 (_cn.scss) 可以更改所有链接和字体,特别是中文版。
但是假设我有这个 mixin 可以输出一些 css 字体:
@mixin font-english($font-size: 16px, $font-weight: 300, $line-height: 22px) {
font-family: "English font";
font-size: $font-size;
font-weight: $font-weight;
line-height: $line-height;
}
body.en .title { @include font-english(14px, 700, 18px); }
有没有办法让它也自动输出中文字体?现在我必须手动完成这一切,url也是一样,我可以写一个mixin,当我使用它时就像
body.en .title { @include background(image.png); }
两个都输出
body.en .title { @include background(http://media.domain.com/image.png); }
和
body.cn .title { @include background(http://media.domain.com.cn/image.png); }
我知道这可能是不可能的,但我只是在寻找更好的解决方案,现在我必须再次检查所有 css 并将 url 和字体更改为中文版本。
【问题讨论】: