什么是css`content`属性的好用途? [英] What are good uses of the css `content` property?

查看:124
本文介绍了什么是css`content`属性的好用途?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

css content 属性是否破坏内容和分隔规则,因为css用于演示不生成内容?

Does the css content property break the rule of content and separation because css is for presentation not to generate content?

css content 属性的其他好用途是什么?我只在 clearfix hacks中看到它。

What are other good uses of the css content property? I've seen it only in clearfix hacks.

推荐答案


csscontent属性是否破坏内容和分隔规则,因为css是用于演示而不是生成内容?

Does css "content" property break the rule of content and separation because css is for presentation not to generation content?

好点。我想说,如果它用于实际数据。

Good point. I'd say it does if it's used for actual data.

quirksmode页 的内容显示了很好的限制。您目前无法添加任何样式的内容 - 它可以使用太少的浏览器。

The quirksmode page on content shows the limitations pretty well. You can't add any kind of styled content at the moment - it will work with too few browsers. You can add only character data.

quirksmode的作者提出了一个有趣的观点:

The author of the quirksmode airs an interesting opinion:


我觉得我们不应该使用内容声明。它向页面添加内容,CSS用于向页面添加演示文稿,而不是内容。因此,我觉得如果你想动态生成内容,你应该使用JavaScript。 CSS是这个工作的错误工具。

I feel that we shouldn't use the content declaration at all. It adds content to the page, and CSS is meant for adding presentation to the page, and not content. Therefore I feel that you should use JavaScript if you want to dynamically generate content. CSS is the wrong tool for this job.

我同意这一点,但有时候,想依靠JavaScript来做这项工作。 Martin所示的逗号例子是一个例子,我发现使用 content 是合理的(虽然我个人会感觉更好,如果逗号已经从服务器端提供 - 这是什么)

I agree with this in general, but sometimes there may be cases where you don't want to rely on JavaScript to do the job. The comma example shown by Martin is a case where I find using content justified (although I personally would be feeling better if the commas would already be served coming from server side - it's what I personally would stick to.)

另外,请记住,通过 content 属性添加逗号和引号可能会导致当您从其他地方(例如在搜索结果页中)查看您的内容时,看起来很糟糕。

Also, keep in mind that adding commas and quotes through the content property may look bad when your content is viewed from elsewhere - for example in a search results page.

如果你真的需要它,我会说得谨慎。

I'd say use it only sparingly, if you really need it.

这篇关于什么是css`content`属性的好用途?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆