具有不扩展元素的宽度的边界 [英] having the border not expanded the width of an element

查看:102
本文介绍了具有不扩展元素的宽度的边界的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

虽然我记得有一个css正确,我可以设置,将允许我设置一个边框,但它不会扩大元素的大小。例如,如果我将宽度设置为100,并且边框的宽度为1,则元素宽度变为102.

I though I remembers there being a css properly that I could set that would allow me to set a border but it would not expand the size of the element. for example, if I set the width to 100 and a border of one 1 all around, the element width becomes 102.

它们的属性是将元素保持为100 ?

Is their a property to keep the element at 100?

推荐答案

您正在考虑 box-sizing:border-box

规格: http://www.w3.org/TR/css3-ui/#box-sizing

#whatever {
    -webkit-box-sizing: border-box;
       -moz-box-sizing: border-box;
            box-sizing: border-box;
}

实用用法信息: http://html5please.com/#box-sizing

浏览器支持: http://caniuse.com/css3-boxsizing

这篇关于具有不扩展元素的宽度的边界的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆