博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
css 相同的css属性_CSS属性,内容和L10N
阅读量:2518 次
发布时间:2019-05-11

本文共 1823 字,大约阅读时间需要 6 分钟。

css 相同的css属性

I have the privilege of working for Mozilla on the Mozilla Developer Network (MDN).  As with any Mozilla-made website, localization is paramount to MDN, so we must be mindful of that when we put text anywhere on the site.  I was recently working on a feature which made use of :  a visual notice on an element's pseudo-element which are experimental and only available to beta testers.  The obvious problem in doing so is that hardcoding the generated content message in the stylesheet means I can't localize it;  a definite localization taboo.  The solution was simple:  use the attr expression to pull the localization message from an element's custom data- attribute.

我有幸在Mozilla开发人员网络(MDN)上为Mozilla工作。 与任何Mozilla制作的网站一样,本地化对MDN至关重要,因此,当我们在网站上的任意位置放置文字时,我们必须谨记这一点。 最近,我正在研究一个利用 :关于元素伪元素的视觉通知,这是实验性的,仅适用于beta测试人员。 这样做的一个明显问题是,在样式表中对生成的内容消息进行硬编码意味着我无法对其进行本地化。 明确的本地化禁忌。 解决方案很简单:使用attr表达式从元素的自定义data-属性中提取本地化消息。

HTML (The HTML)

Start by outputting the localized text to a data- attribute:

首先将本地化文本输出到data-属性:

With the text available in an attribute, the CSS attr expression and content will be used to display the text in a pseudo-element:

在属性中有可用文本的情况下,CSS attr表达式和content将用于以伪元素显示文本:

.beta-feature:after {	content: attr(data-message);	/* formatting here */}

The formatting is up to the developer but the main point is that we get to use the attribute value to display the variable text.

格式取决于开发人员,但主要要点是我们可以使用属性值来显示变量文本。

This post isn't groundbreaking and it's not meant to be;  I just want to reinforce how awesome and useful CSS content paired with attr can be.  I love that this strategy prevents the need to preprocess CSS files with the localized text, and love that...it's just so easy!

这篇文章不是开创性的,也不意味着是。 我只想强调与attr配对的真棒和有用CSS content 。 我喜欢这种策略,无需使用本地化的文本对CSS文件进行预处理,因此...非常简单!

翻译自:

css 相同的css属性

转载地址:http://zgswd.baihongyu.com/

你可能感兴趣的文章
bloc控制读写文件
查看>>
微信小程序
查看>>
预培训-阅读-快速阅读并提问
查看>>
拓展KMP以及模板
查看>>
洛谷 P3049 Landscaping ( 贪心 || DP)
查看>>
洛谷 P1059 明明的随机数
查看>>
python 基础大纲
查看>>
window自动任务实现数据库定时备份
查看>>
Windows 7 Ultimate(旗舰版)SP1 32/64位官方原版下载(2011年5月12日更新版)
查看>>
javascript操作cookie
查看>>
深入理解HTTP协议(转)
查看>>
NHibernate讲解
查看>>
客户端—表单验证信息—并能否提交到数据库
查看>>
Android开发环境搭建(原创)
查看>>
java IO流 对文件操作的代码集合
查看>>
js / jquery 获取和设置 FCK Editor 的值
查看>>
OpenJudge计算概论-与7无关的数
查看>>
proxy-target-class="true" 与proxy-target-class="false"的区别
查看>>
npm安装包很慢
查看>>
jquery是如何清除ajax缓存的
查看>>