【发布时间】:2011-03-07 08:06:05
【问题描述】:
我希望红色方块与绿色方块完全重叠。 在 FF、IE 和 Opera 中一切正常,但在 Chrome 红色方块中向左对齐,而不是居中。 此外,我只能影响#parent div 及其子元素,因为我制作了一个书签,我无法更改其他页面元素。
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=UTF-8" />
<title></title>
<style type="text/css">
#center { text-align: center; }
#parent {
position: absolute;
display: inline;
}
#nested {
background-color: #c00;
width: 280px !important;
height: 210px !important;
}
</style>
</head>
<body>
<div id="center">
<div id="parent"><div id="nested"></div></div>
<div style="display: inline-block; width: 280px; height: 210px; background-color: #0c0;"></div>
</div>
</body>
</html>
请指教!
当我详细说明 chrome 属性时,我发现当您将 #parent 的位置设置为绝对时,chrome 会强制显示阻塞。如何使其内联?
【问题讨论】:
标签: html css google-chrome alignment css-position