反正我是否可以将css值写成数学表达式?例:
div{
height: 50% + 30px;
width: 40em - 5px;
}
Run Code Online (Sandbox Code Playgroud)
如果有,那将是完美的.
PS:我不想用JS或JQuery来做.
san*_*eep 26
你可以用css3 calc()实现这个目的.像这样写:
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;
}
Run Code Online (Sandbox Code Playgroud)
检查这个http://jsfiddle.net/3QUw6/
查看此讨论了解更多是否可以在CSS3中使div 50px小于100%?