CSS值作为数学表达式

编程入门 行业动态 更新时间:2024-10-17 21:20:38
本文介绍了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值作为数学表达式

本文发布于:2023-11-10 16:18:30,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1575866.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:表达式   数学   CSS

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!