盒子模型
2018-01-16 22:23
78 查看
1 边框(border)
Border-top-style: solid 实线 dotted 点线 dashed 虚线
Border-top-color 边框颜色
Border-top-width 边框粗细
边框属性的连写没有顺序要求,线型为必写项。
边框合并 border-collapse:collapse;用于细边框表格
2 获取焦点
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<style type="text/css">
.input1 {
border:0 none;
outline-style: none;
background: #eee;
border: 1px #666 dashed;
}
.input2 {
border:0 none;
outline-style: none;
border-bottom: 1px #f00 dotted;
}
.input3 {
background: url(../../04/练习/1.jpg) right no-repeat;
}
.input1:focus {
background-color: red;
}
</style>
</head>
<body>
<label for="input4">1</label> <input type="text" class="input1" id="input4"><br><br>
2<input type="text" class="input2"><br><br>
3<input type="text" class="input3"><br><br>
</body>
</html>结果就是当标签input4得到焦点时,input1也获得焦点,也就是可以输入文字。
3 内边距
◆内边距撑大盒子的问题
影响盒子宽度的因素 (1)内边距影响盒子的宽度(2)边框影响盒子的宽度
盒子的宽度=定义的宽度+边框宽度+左右内边距
被撑大的区域会被背景填充,看起来就像被撑大,其中嵌套的控件会有间距,但是自身可以在内边距中写控件。
◆继承的盒子一般不会被撑大
包含(嵌套)的盒子,如果子盒子没有定义宽度,给子盒子设置左右内边距,一般不会撑大盒子。当控件宽度超过盒子的宽度会撑大。
高度同。
4 外边距
◆垂直方向外边距合并
两个盒子垂直一个设置上外边距,一个设置下外边距,取的设置较大的值。
◆嵌套的盒子外边距塌陷
解决方法: 1给父盒子设置边框
2给父盒子overflow:hidden; bfc 格式化上下文
Border-top-style: solid 实线 dotted 点线 dashed 虚线
Border-top-color 边框颜色
Border-top-width 边框粗细
边框属性的连写没有顺序要求,线型为必写项。
边框合并 border-collapse:collapse;用于细边框表格
2 获取焦点
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<style type="text/css">
.input1 {
border:0 none;
outline-style: none;
background: #eee;
border: 1px #666 dashed;
}
.input2 {
border:0 none;
outline-style: none;
border-bottom: 1px #f00 dotted;
}
.input3 {
background: url(../../04/练习/1.jpg) right no-repeat;
}
.input1:focus {
background-color: red;
}
</style>
</head>
<body>
<label for="input4">1</label> <input type="text" class="input1" id="input4"><br><br>
2<input type="text" class="input2"><br><br>
3<input type="text" class="input3"><br><br>
</body>
</html>结果就是当标签input4得到焦点时,input1也获得焦点,也就是可以输入文字。
3 内边距
◆内边距撑大盒子的问题
影响盒子宽度的因素 (1)内边距影响盒子的宽度(2)边框影响盒子的宽度
盒子的宽度=定义的宽度+边框宽度+左右内边距
被撑大的区域会被背景填充,看起来就像被撑大,其中嵌套的控件会有间距,但是自身可以在内边距中写控件。
◆继承的盒子一般不会被撑大
包含(嵌套)的盒子,如果子盒子没有定义宽度,给子盒子设置左右内边距,一般不会撑大盒子。当控件宽度超过盒子的宽度会撑大。
高度同。
4 外边距
◆垂直方向外边距合并
两个盒子垂直一个设置上外边距,一个设置下外边距,取的设置较大的值。
◆嵌套的盒子外边距塌陷
解决方法: 1给父盒子设置边框
2给父盒子overflow:hidden; bfc 格式化上下文
相关文章推荐
- css 标准盒子模型和ie盒子模型的区别和各自的特点
- 什么是CSS的盒子模型
- W3C盒子模型的设置
- css基础-盒子(div)模型、属性、边框线的设置、padding、margin、网站的设置思想(float),图片代替列表符号
- webBasic_day03_CSS_选择器_hover_盒子模型(padding, margin)
- 盒子模型(DIV+CSS)
- css知多少(7)——盒子模型
- 盒子模型
- css 盒子模型理解
- CSS:盒子模型与定位
- [html+css]HTML+CSS基础课程:元素分类 和 盒子模型 笔记
- 盒子模型之margin重叠深度分析
- 认识CSS中盒子模型
- html5 盒子模型案例
- CSS 盒子模型
- 关于ie的盒子模型bug
- IE6的盒子模型
- 从所谓“IE6盒子模型”说起
- 标准W3C盒子模型和IE盒子模型(错了无数次)
- css 盒子模型理解