Stylesheet_link_tag:all与:media => all [英] Stylesheet_link_tag :all versus :media =>all

查看:103
本文介绍了Stylesheet_link_tag:all与:media => all的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从脚手架创建了一个新的Rails应用程序,但本教程声称将出现以下内容:

I created a new Rails application from a scaffold, but the tutorial claims the following will appear:

<%= stylesheet_link_tag    "application", :media => "all" %>

当我得到:

<%= stylesheet_link_tag    :all %>

它们之间有什么区别?我应该使用哪个?为什么?

What is the difference between them? Which should I use? Why?

推荐答案

使用

<%= stylesheet_link_tag    "application", :media => "all" %>

将包含名为 application.css 的样式表,您可以拥有 application.css.sass application.css.scss 之类的文件,或者其他任何扩展名和rails都将使用正确的样式表引擎编译css文件并提供application.css文件.

will include the stylesheet named application.css, you can have files like application.css.sass or application.css.scss or any other extensions and rails will compile the css file with the right stylesheet engine and serve the application.css file.

属性"media = all" 实际上是css属性,这意味着所有媒体都将包含css,例如浏览网站,打印屏幕等时.可以在此链接上找到有关媒体属性的更多信息.

The attribute "media=all" is actually a css attribute, which means that the css will be included for all the medias, like when browsing the website, when printing the screen, etc. You can find more information about the media attribute on this link.

通过使用

<%= stylesheet_link_tag    :all %>

您将包括在 app/assets/stylesheets 目录中的所有样式表.

you will include all the stylesheets that you have on your app/assets/stylesheets directory.

您可以在此链接上找到更多信息.

这篇关于Stylesheet_link_tag:all与:media =&gt; all的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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