本文介绍了CSS值作为数学表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有反正我可以写一个css值作为数学表达式? 例如:
Is there anyway that I can write a css value as mathematical expression? Example:
div{ height: 50% + 30px; width: 40em - 5px; }如果有,这将是完美的。 PS:我不想使用 JS 或 JQuery 。
If there is, it would be perfect. PS: I don't want to do it with JS or JQuery.
推荐答案您可以使用css3 calc()。这样写:
You can achieve this with css3 calc(). Write like this:
div{ width: 40%; width: -webkit-calc(40% - 5px); width: -moz-calc(40% - 5px); width: calc(40% - 5px); height:50%; height: -webkit-calc(50% + 50px); height: -moz-calc(50% + 50px); height: calc(50% + 50px); background: green; color: white; position:absolute; }检查此jsfiddle/3QUw6/
查看此讨论以了解更多在CSS3中使div 50px小于100%是可能的吗?
Check this discussion for more Is it possible to make a div 50px less than 100% in CSS3?
更多推荐
CSS值作为数学表达式
发布评论