是否有可能使CSS 50中的div 50px小于100%? [英] Is it possible to make a div 50px less than 100% in CSS3?
问题描述
是否可以使纯CSS中的 div
50px小于100%?我想要< div>
只有50px小于100%。我不想要任何JavaScript。
Is it possible to make a div
50px less than 100% in pure CSS? I want the <div>
to be only 50px less than 100%. I don't want any JavaScript.
推荐答案
是的,可以。没有使用IE的 expression()
,你可以在CSS3中使用 calc()
。
Yes you can. Without using the IE's expression()
, you can do that in CSS3 by using calc()
.
div {
width: 100%;
width: -webkit-calc(100% - 50px);
width: -moz-calc(100% - 50px);
width: calc(100% - 50px);
}
演示: http://jsfiddle.net/thirtydot/Nw3yd/66/
这会让你的生活这么容易。它目前在3个主要浏览器中支持:Firefox,Google Chrome(WebKit)和IE9: http://caniuse.com/ calc
This will make your life so much easier. It is currently supported in the 3 main browsers: Firefox, Google Chrome (WebKit), and IE9: http://caniuse.com/calc
MDN: https://developer.mozilla.org/en/CSS/-moz-calc
这篇关于是否有可能使CSS 50中的div 50px小于100%?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!