Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/34.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/61.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在haml中转换css样式语法_Css_Ruby On Rails_Haml - Fatal编程技术网

如何在haml中转换css样式语法

如何在haml中转换css样式语法,css,ruby-on-rails,haml,Css,Ruby On Rails,Haml,我进错房间了 如何正确转换 因为当我加载页面时,haml没有呈现相同的html HTML 你可能想试试 输入: <style media="screen"> img { display: none; } body { overflow: hidden; } #canvas { position: absolute; top: 0; left: 0; } </style> 无论如何,作为Mandeep,我还建议您将样式移动到样式表中这应

我进错房间了

如何正确转换

因为当我加载页面时,haml没有呈现相同的html

HTML 你可能想试试

输入:

<style media="screen">
      img { display: none; }
      body { overflow: hidden; }
      #canvas { position: absolute; top: 0; left: 0; }
</style>
无论如何,作为Mandeep,我还建议您将样式移动到样式表中

这应该可以

%body
  :css
    img { display: none; }
    body { overflow: hidden; }
    #canvas { position: absolute; top: 0; left: 0; }

但这是一个不好的做法来呈现html内容,这些内容应该位于单独的文件中。

这应该适合您,以防您的代码中不需要CDATA标记

%style{media: "screen"}
  :plain
    img { display: none; }
    body { overflow: hidden; }
    #canvas { position: absolute; top: 0; left: 0; }

为什么要使用内联样式?将它们移动到AssetSing inline可以方便地测试某些东西是否工作,而无需重新编译资产;如果有效,则可以将其移动到资产出于动机,电子邮件布局需要内联样式表。使用内联样式是一种不好的做法这不包括
media=“screen”
属性。您需要使用实际的标记(例如
%style(media=“screen”)
)才能获取属性。
%style{:media => "screen"}
  img { display: none; }
  body { overflow: hidden; }
  \#canvas { position: absolute; top: 0; left: 0; }
%body
  :css
    img { display: none; }
    body { overflow: hidden; }
    #canvas { position: absolute; top: 0; left: 0; }
%style{media: "screen"}
  :plain
    img { display: none; }
    body { overflow: hidden; }
    #canvas { position: absolute; top: 0; left: 0; }