CSS3与变量计算 [英] CSS3 calc with variables

查看:153
本文介绍了CSS3与变量计算的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



有没有可能在css3中有这样一个变量:

  .someClass {
width:-moz-calc(nrOfChilds * 80px);
}

我得到的其他一些类是这样写的:

  .anotherClass:nth-​​child(n){
margin-left:-moz-calc(n * 50px);



$ b $ p
$ b $ p是可以使用一些像n或nrOfChilds这样的变量吗?现在我多次声明我的第二个例子,并手动更改第一个例子?
我知道javascript是一个解决方案。但是有没有一个本地css3解决方案呢?



/亲切的问候



基督徒

解决方案

查看 LESS 或<如果使用.NET服务器端,则可以使用 less

I am calculating some widths and margins depending on the number of childs.

Is it possible in css3 to have a variable like:

.someClass {
   width: -moz-calc(nrOfChilds * 80px);
}

Some other classes I got are written as follows:

.anotherClass:nth-child(n) {
   margin-left: -moz-calc(n * 50px);
}

Is it possible to use some variables like n or nrOfChilds? At the moment I declare my second example several times and change the first manually? I know javascript is a solution to this. But is there a native css3 solution for this?

/Kind regards

Christian

解决方案

Have a look at LESS or .less if using .NET server side.

这篇关于CSS3与变量计算的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆