gpt4 book ai didi

css 属性值包含变量

转载 作者:太空宇宙 更新时间:2023-11-04 15:18:33 24 4
gpt4 key购买 nike

在使用较少的 css 设置属性值时如何包含变量。例如:

我想根据变量@direction将背景图片设置在右边或左边。

我试过:

@direction:left;
background: url(../../images/downarrow_blue.png) no-repeat @direction white;

但它不起作用。

最佳答案

您有 2 个问题:

  1. 要传递字符串值变量,您应该将它们括在单引号中。在您的情况下,它应该是 @direction: 'left';
  2. background-position 属性接受对应于每个轴的两个值。您需要传递如下内容:@direction: 'left top';@direction: 'right bottom';

查看与变量相关的文档:http://lesscss.org/#-variables

关于css 属性值包含变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14819889/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com