Php 从另一个文件[Symfony2]使用较少的类
我正在使用Symfony2,我的样式表使用的更少。 尝试使用其他文件中的类时出错: 在我的main.less文件中:Php 从另一个文件[Symfony2]使用较少的类,php,css,symfony,less,Php,Css,Symfony,Less,我正在使用Symfony2,我的样式表使用的更少。 尝试使用其他文件中的类时出错: 在我的main.less文件中: .noBorderNoOutline { border : none !important; outline : none !important; } 在我的forms.less文件中,我执行以下操作: @import 'main.less'; input, select { .noBorderNoOutline(); width : 25
.noBorderNoOutline { border : none !important; outline : none !important; }
在我的forms.less文件中,我执行以下操作:
@import 'main.less';
input, select {
.noBorderNoOutline();
width : 250px;
height : 50px !important;
box-shadow : 0 0 2px #555 !important;
border : 1px #aaa solid !important;
padding-left : 10px;
margin-bottom : 10px;
}
我使用LESSHPP编译更少的文件和yui压缩程序,我的配置是:
filters:
yui_css:
jar: "%kernel.root_dir%/Resources/java/yuicompressor.jar"
yui_js:
jar: "%kernel.root_dir%/Resources/java/yuicompressor.jar"
cssrewrite: ~
lessphp:
apply_to: "\.less$"
formatter: "lessjs"
preserve_comments: true
presets:
my_variable: "#000"
这些文件位于同一捆绑包和同一文件夹中
在我的小树枝模板中,我执行以下操作:
{% stylesheets filter='yui_css'
'@MyBundle/Resources/public/css/forms.less'
%}
<link rel="stylesheet" type="text/css" href="{{ asset_url}}" />
{% endstylesheets %}
{%stylesheets过滤器='yui\u css'
“@MyBundle/Resources/public/css/forms.less”
%}
{%endstylesheets%}
我有一个错误:加载资源失败:服务器响应状态为500(内部服务器错误)
类“noBorderNoOutline”未定义
感谢您的帮助。如果mixin没有参数,则无需将其用作函数。但是,您确实需要将其定义为main.less文件中的函数 定义如下:
.noBorderNoOutline() { border : none !important; outline : none !important; }
input, select {
.noBorderNoOutline;
width : 250px;
height : 50px !important;
box-shadow : 0 0 2px #555 !important;
border : 1px #aaa solid !important;
padding-left : 10px;
margin-bottom : 10px;
}
像这样使用它:
.noBorderNoOutline() { border : none !important; outline : none !important; }
input, select {
.noBorderNoOutline;
width : 250px;
height : 50px !important;
box-shadow : 0 0 2px #555 !important;
border : 1px #aaa solid !important;
padding-left : 10px;
margin-bottom : 10px;
}
希望这能解决你的问题:)祝你好运 很抱歉,我遇到了相同的错误:NameError:.noBorderNoOutline未定义能否尝试调试它是编译器脚本还是实际较少的文件?尝试使用winless或其他less编译器编译less文件,并在项目中手动包含结果。看看它抛出了什么错误。我尝试在命令行中编译文件:lessc directory/*>style.css,它可以工作。我没有错误,但在Symfony上也有同样的问题。我不知道你的答案…这可能是编译器正在采取的步骤的问题,然后,你可以尝试将文件重新排列成一个all.less文件,该文件@首先导入main.less,然后再导入form.less。然后,您应该从form.less中删除import main.less。然后将生成的all.css包含在您的站点中。是的,它与主文件一起工作!谢谢你的帮助!