盒子模型-margin的使用
来源:互联网 发布:爱迪星微信营销软件 编辑:程序博客网 时间:2024/06/07 06:27
margin:两个盒子之间的距离
可以使用
<style>
div{
margin:20px;
}
</style>
这样子的话,所有的div的边距都是20px的距离
如果使用#test{
margin:20px;
}
那么id为test的标签则为20px
但是这种指定方法是标签的四个方向都指定为20px,如果需要指定上下左右,则可以使用
margin-top:20px;
margin-right:30px;
margin-botton:40px;
margin-left:50px;
可以这样设置,或者也可以只用以下的方式来设置
margin:10px,20px,那么上下都是10px,左右都是20px.因为是先从上面开始分配,然后顺时针分配,如果没分配到的话,则取对边的值。
如果是margin:10px,20px,30px.那么上下分别是10px,30px,左右是20px
如果是margin:10px,20px,30px,40px,那么上下左右分别是10px,30px,20px,40px.
<style>
#cont{
width:1000px;
height:600px;
background: green;
}
div {
width:400px;
height:200px;
float:left;
}
#test{
/*
margin:10px;
*/
/*
margin-top:10px;
margin-left: 20px;
margin-bottom: 30px;
margin-right: 40px;
*/
/*margin:10px 20px;*/
margin: 10px 20px 30px;
background: red;
}
#test2 {
background: orange;
}
#test3{
width:1000px;
background: blue;
}
</style>
</head>
<body>
<div id="cont">
<div id="test"></div>
<div id="test2"></div>
<div id="test3"></div>
</div>
</body>
</html>
可以使用
<style>
div{
margin:20px;
}
</style>
这样子的话,所有的div的边距都是20px的距离
如果使用#test{
margin:20px;
}
那么id为test的标签则为20px
但是这种指定方法是标签的四个方向都指定为20px,如果需要指定上下左右,则可以使用
margin-top:20px;
margin-right:30px;
margin-botton:40px;
margin-left:50px;
可以这样设置,或者也可以只用以下的方式来设置
margin:10px,20px,那么上下都是10px,左右都是20px.因为是先从上面开始分配,然后顺时针分配,如果没分配到的话,则取对边的值。
如果是margin:10px,20px,30px.那么上下分别是10px,30px,左右是20px
如果是margin:10px,20px,30px,40px,那么上下左右分别是10px,30px,20px,40px.
<style>
#cont{
width:1000px;
height:600px;
background: green;
}
div {
width:400px;
height:200px;
float:left;
}
#test{
/*
margin:10px;
*/
/*
margin-top:10px;
margin-left: 20px;
margin-bottom: 30px;
margin-right: 40px;
*/
/*margin:10px 20px;*/
margin: 10px 20px 30px;
background: red;
}
#test2 {
background: orange;
}
#test3{
width:1000px;
background: blue;
}
</style>
</head>
<body>
<div id="cont">
<div id="test"></div>
<div id="test2"></div>
<div id="test3"></div>
</div>
</body>
</html>
0 0
- 盒子模型-margin的使用
- 如何使用好div盒子模型的margin和padding
- 盒子模型-margin,padding
- 盒子模型 margin和padding和盒子大小的影响
- 盒子模型1 margin padding
- 盒子模型里面的margin属性和padding属性杂记
- 关于子盒子模型有margin-top的时候,父盒子模型也同时拥有margin-top的解决方法
- css中对于盒子模型margin属性的思考---margin折叠问题
- html06 盒子模型 margin border padding
- 盒子模型之margin重叠深度分析
- 使用弹性盒子模型的一些思考
- css盒子模型 css margin 外边框合并
- css盒子模型 css margin 外边框合并
- IE6 的盒子模型
- jQuery的盒子模型
- DIV的盒子模型
- CSS的盒子模型
- 盒子模型的基础
- Java方法参数太多怎么办—Part5—方法命名
- Java方法参数太多怎么办—Part6—方法返回值
- MySQL Schema设计(四)一个MySQL里的JQuery:common_schema
- UIViewContentModeScaleAspectFill不凑效的解决办法
- Linux下安装openldap
- 盒子模型-margin的使用
- PHP MYSQL注入攻击需要预防7个要点
- HBase使用场景和成功案例
- Side Project - 愛羽球 v1.2.3上架了,但是。。。
- Chrome源码剖析、上
- Visual Studio 2010 快捷键
- Sencha Touch跨域问题解决
- HBase性能调优
- Codeforces 389B Fox and Cross(dfs)