chrome margin失效的解决办法可以尝试在第一个div中加入overflow:hidden;
测试代码,注意红色部分:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<style type="text/css">
<!--
body{
background-color:#AEB9F4;
}
#div1{
width:602px;
height:602px;
margin:20px auto;
background-color:#EDD923;
overflow:hidden; /* 这行是添加的 */
}
#div1 #div2{
margin-top:120px;
margin-right:20px;
margin-bottom:20px;
margin-left:20px;
width:560px;
height:560px;
border:1px solid #000;
}
-->
</style>
</head>
<body>
<div id="div1">
<div id="div2"></div>
</div>
</body>
</html>
发表评论:
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。
相关文章
通过CSS截取文字长度2023-01-02
display:inline-block 水平居中无效的解决办法2019-03-07
CSS中font-family:中文字体的英文名称 2018-11-06
css3 nth-child选择器2018-11-04
CSS3 transform多种组合2018-10-26
scrollbar CSS美化(仿Safari样式)2013-10-28
CSS样式在IE6中失效的解决方案2013-05-06
Firefox及Chrome中div不撑高的解决办法2013-04-30
使用css调整文字间距2013-04-10
div 垂直居中完美解决办法2013-03-18