【问题标题】:How to put Javascript in Sass?如何将 Javascript 放入 Sass 中?
【发布时间】:2017-05-14 14:38:11
【问题描述】:

所以我把这段代码放在我的 Sass 文件中

width: 100%;
height: auto;
overflow: hidden;
display: block;
display: -webkit-box;
height: $ font-size *$ line-height *$ lines-to-show;
font-size: $ font-size;
-webkit-line-clamp: 3;
-webkit-box-orient: vertical;
text-overflow: ellipsis;

代码限制了应该显示多少行,


但它不适用于 Sass

我不知道如何解决这个问题

我搜索了这种问题,但我找不到它..

【问题讨论】:

    标签: html css sass compass-sass


    【解决方案1】:

    您需要更改变量 ($sampleVariable) 并删除 $ 后面的空格。此外,您还需要定义在文件顶部使用的那些变量以进行编译。

    您的示例代码可能是这样的:

    // variable definition
    $font-size: 1em;
    $line-height: 1.3;
    $lines-to-show: 3;
    
    // rest of the code
    .selector {
       width: 100%;
       height: auto;
       overflow: hidden;
       display: block;
       display: -webkit-box;
       height: $font-size * $line-height * $lines-to-show; // no spaces between $ and variable name
       font-size: $ font-size;
       -webkit-line-clamp: 3;
       -webkit-box-orient: vertical;
       text-overflow: ellipsis;
    }
    

    【讨论】:

    • 如果这回答了你的问题,你能把它标记为答案吗?
    • 当然,抱歉我忘记了
    猜你喜欢
    • 2011-03-21
    • 1970-01-01
    • 1970-01-01
    • 2016-09-20
    • 2020-08-12
    • 2013-02-12
    • 2018-08-17
    • 1970-01-01
    • 2011-02-03
    相关资源
    最近更新 更多