本文介绍了是否有可能使CSS 50中的div 50px小于100%?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以使纯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中使用。
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);
}
演示:
这会让你的生活这么容易。它目前在3个主要浏览器中支持:Firefox,Google Chrome(WebKit)和IE9:
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:
这篇关于是否有可能使CSS 50中的div 50px小于100%?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!