stackoverflow - Css3 calc()定制自适应宽度
伊谢尔伦
伊谢尔伦 2017-04-17 11:04:13
0
1
639

casperOne:我想用CSS设置一个50px的 p ,不能超过100%宽度,也不用JavaScript。如何实现?

伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

reply all(1)
大家讲道理

Derek: can be implemented, but you don’t need to use IE’s expression(), but use Calc() in CSS3.

p {
    width: 100%;
    width: -webkit-calc(100% - 50px);
    width: -moz-calc(100% - 50px);
    width: calc(100% - 50px);
}

Demo: http://jsfiddle.net/thirtydot/Nw3yd/66/

This is very convenient, but it should be noted that there are currently only 3 browsers that support CSS3: Firefox, Google Chrome (WebKit) and IE9

Detailed explanation of Calc attribute: https://developer.mozilla.org/zh-CN/docs/CSS/calc

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template