如何在CSS中使用变量? [重复]

时间:2022-09-10 16:47:55

Possible Duplicate:
Create a variable in .CSS file for use within that .CSS file

可能重复:在.CSS文件中创建一个变量,以便在该.CSS文件中使用

I heard about that we can declare/define variable in CSS and use them like global variables like this:

我听说我们可以在CSS中声明/定义变量并像使用全局变量一样使用它们:

@nice-blue: #5B83AD;

#header { color: @nice-blue; }

So anyone knows how to use them?

所以任何人都知道如何使用它们?

3 个解决方案

#1


35  

For that you need to use Less or Sass which are CSS Dynamic languages.

为此,您需要使用Less或Sass这些是CSS动态语言。

here's some comparison between both technologies.

这是两种技术之间的比较。

#2


5  

You need to use something like SASS

你需要使用像SASS这样的东西

http://sass-lang.com/#variables

http://sass-lang.com/#variables

or Less

或更少

http://lesscss.org/

http://lesscss.org/

#3


5  

There is a language written on top of CSS which make use of variables like you asked, it's called LessCSS

有一种语言写在CSS之上,它使用了你所问的变量,它被称为LessCSS

#1


35  

For that you need to use Less or Sass which are CSS Dynamic languages.

为此,您需要使用Less或Sass这些是CSS动态语言。

here's some comparison between both technologies.

这是两种技术之间的比较。

#2


5  

You need to use something like SASS

你需要使用像SASS这样的东西

http://sass-lang.com/#variables

http://sass-lang.com/#variables

or Less

或更少

http://lesscss.org/

http://lesscss.org/

#3


5  

There is a language written on top of CSS which make use of variables like you asked, it's called LessCSS

有一种语言写在CSS之上,它使用了你所问的变量,它被称为LessCSS