Safari 4似乎忽略了元素边距,除非我添加边框.
以下示例呈现左右边距但没有顶部或底部.
添加边框后,它会按预期呈现.我做错了什么,或者我是否必须(albeit transparent ones)为每个带边距的元素添加边框?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>testing</title>
<style>
body {background-color:#666;}
div {display:block; position:relative; margin:0; padding:0;}
.background {background-color:#990000;}
.foreground {background-color:#fff; margin:10px; padding:10px;}
</style>
</head>
<body>
<div class='background'>
<div class='foreground'>
foreground
</div>
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
这是一种正常的奇怪行为,称为边缘(编辑,对不起,我是法国人)崩溃.简单地避免它添加overflow:auto;到容器上.
.background {background-color:#990000; overflow:auto;}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6047 次 |
| 最近记录: |