margin-top、margin-bottom的一些分析
margin-top:表示该容器距离上面容器的距离
情况一:如果该容器上面没有容器,则这个样式属性则被父容器占用了
html代码如下:
<div id ="fa">
<div id="son"></div>
<div style="height:30px; background:#ffd800;"></div>
</div>
<div id="br"></div>
css代码如下:
#fa {
width:600px;
height:600px;
background:#f00;
}
#son {
width:200px;
height:200px;
background:#4cff00;
margin-top:30px;
}
结果图如下:

情况二:如果该容器上面有容器,则父容器不占用这个样式属性
html代码如下:
<div id ="fa">
<div style="height:30px; background:#ffd800;"></div>
<div id="son"></div>
<div style="height:30px; background:#ffd800;"></div>
</div>
<div id="br"></div>
css代码如下:
#fa {
width:600px;
height:600px;
background:#f00;
}
#son {
width:200px;
height:200px;
background:#4cff00;
margin-top:30px;
}
结果图如下:

如何解决情况一的问题:设置父容器超出的隐藏的样式属性overflow:hidden;
margin-top、margin-bottom的一些分析的更多相关文章
- margin的auto的理解 top,left[,bottom,right] position
auto auto 总是试图充满父元素 margin有四个值: All the margin properties can have the following values: auto - the ...
- 定位(left 、right 、top 、 bottom)、padding、margin 值设为百分比值时
定位(left .right .top . bottom): top 为例 right 为例 padding.margin : 当padding.margin 值设为百分比值时,其百分比会相对于父元素 ...
- top:0;bottom:0;left:0;right:0;同时使用的效果
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- 关于定位中left和right,top和bottom的权重问题
关于定位中left和right,top和bottom的权重问题 在共同类中设置了定位并且设置了left等定位,如果你引用这个类并加入其他的类中也有left和right等定位,那么你设置的right或是 ...
- Moving From Top To Bottom in Detailed Block in Oracle Forms
Suppose you want to scan a tabular grid block (loop through all records in detail block) from top to ...
- The Portable Executable File Format from Top to Bottom(每个结构体都非常清楚)
The Portable Executable File Format from Top to Bottom Randy KathMicrosoft Developer Network Technol ...
- 绝对定位元素left、right、top、bottom值与其margin和宽高的关系
绝对定位元素(position: absolute)在其相对定位元素(即文档流中最近的非静态定位祖先元素)中,定位祖先元素的宽度为W,垂直高度为H,则存在以下关系: 元素水平方向 width + le ...
- 左右margin top问题百分比值
不想说今天心情有多差! 9点多開始发现一个"bug",需求是依据屏幕高度动态调整某个div的位置.代码大概是这种. <div style="margin-top: ...
- margin top 无效
常出现两种情况: (一)margin-top失效 两个层box1和box2,box1具有浮动属性,box2没有,这时候设置box2的上边距margin-top没有效果. 解决办法: 1.box2增加f ...
- css top,right,bottom,left设置为0有什么用?它和width:100%和height:100%有什么区别?
壹 ❀ 引 当我们使用position属性时,总免不了与top,left,right,bottom四个属性打交道,那么这四个属性都设置为0时有什么用,与宽高设置100%又有什么区别?本文对此展开讨论 ...
随机推荐
- [MySQL]mysql指定路径启动
/usr/sbin/mysqld --defaults-file=/etc/mysql/my.cnf --basedir=/usr --datadir=/var/lib/mysql --pid-fil ...
- EasyUI--datebox设置默认时间
1. html代码: <input id="txtBeginTime" class="easyui-datebox" data-options=" ...
- html 转义
function escapeHTML(n) { var t = document.createElement("div"), i = document.createTextNod ...
- PHP根据设备类型自动跳转相应网址页面,这个现在实用
现在移动设备上网也很方便,比如Android智能手机,iPhone/iPad等,很多网站都相继推出了针对电脑和这些手机等移动设备访问的网页,如果你的系统是用PHP写的,那面本代码对你会很实用,可根据这 ...
- mysql常用博客论坛
大神博客: starive的博客:http://blog.itpub.net/26435490/viewspace-1133659/ 北在南方的博客:http://blog.itpub.net/226 ...
- bootstrap的alert提示框的关闭后再显示问题
bootstrap中有alert组件,如果点击关闭按钮后该组件会被删除而不是被隐藏,想再显示怎么办呢? bootstrap-alert.js源码片段: function removeElement() ...
- Android3.0 以前的Fragment支持
Fragment非常实用,Android也为3.0以前的平台增加了Fragment支持,只是该Fragment不是继承android.app.Fragment,而是继承android.support. ...
- multipathd dead but pid file exists
构建RAC环境时出现的错误 百度半天未找到解决方案,Google了一下,终于找到可行方案 Solution:- yum update device-mapper glibc -y [root@HE2 ...
- Windows Server 2008 R2 允许远程桌面连接这台计算机是灰色解决办法
发现在给"远程协助"打钩时,是灰色的没法钩上,也就没办法开启.这是因为Windows Server 2008 R2的安全性已经被微软设计的很高,默认刚安装上Windows Serv ...
- IM比较SipDroid/IMSDroid/CSipsimple/Linphone/Webrtc
一) sipdroid1)架构sip协议栈使用JAVA实现,音频Codec使用skype的silk(Silk编解码是Skype向第三方开发人员和硬件制造商提供免版税认证(RF)的Silk宽带音频编码器 ...