css:box-sizing使用教程

本文介绍了css3中的box-sizing属性,在这之前读者需要预备知识width的范围。

浏览器的支持情况

Browser Suppored Notes
Internet Explorer Yes version 8.0
Mozilla Firefox Yes 29.0 2.0 -moz-
chrome Yes 10.0 4.0 -webkit-
opera Yes version 9.5
Safari Yes 5.1 3.2 -webkit-

box-sizing属性

box-sizing属性可以有三个值:content-box(defalut),border-box属性。

  1. content-box,border和padding不计算入width之内。
  2. border-box,border和padding计算入width之内。

<style>

div{

width:100px;

height:100px;

border:20px solid yellow;

padding:20px;

background:green;

background-clip:content-box;

}

.content-box{

box-sizing:content-box;

}

.border-box{

box-sizing:border-box;

}

</style>View Code

相关推荐
Serendipity_Carl1 天前
Django入门-小白教程
后端·python·pycharm·django·html5
梦6502 天前
【前端实战】图片元素精准定位:无论缩放,元素始终钉在指定位置
前端·html·css3
ヤ鬧鬧o.2 天前
IDE风格的布局界面
javascript·html5
qq_406176142 天前
什么是模块化
开发语言·前端·javascript·ajax·html5
HIT_Weston3 天前
85、【Ubuntu】【Hugo】搭建私人博客:文章目录(四)
linux·ubuntu·html5
程序员刘禹锡3 天前
定位与图标字体知识点全解析!!!(12.31)
前端·css·html·css3
hxjhnct3 天前
CSS中px,em,rem的区别
javascript·css·css3
谷哥的小弟3 天前
HTML5新手练习项目—新年祝福(附源码)
前端·源码·html5·项目
MoonPointer-Byte4 天前
[特殊字符]The Omniscient Tome | 全知之书
javascript·html5
行思理4 天前
css 样式新手教程
前端·css·html5