【发布时间】:2012-05-01 21:46:02
【问题描述】:
案例#1:
我想在默认 WordPress 主题 (http://twentyelevendemo.wordpress.com/) 的标题中的照片上方放置一个徽标
我的解决方案:在照片前添加标志,并在其上设置position: absolute,无需设置任何top/left/bottom/right属性:
HTML:
<a id="header">
<img id="logo">
<img id="photo">
</a>
CSS:
#logo {
position: absolute;
margin: 10px;
/* or padding: 10px; */
/* or border: 10px solid transparent;
only this works with my elderly iPhone Simulator.app */
}
案例#2:
另一个例子是一个水平的多级菜单,它是 100% 宽并用display: table-* 布局,但table-cells 不支持position: relative,所以我唯一的解决方案是:http://jsfiddle.net/pCe49/
它适用于 IE6-7、Firefox1.5,不适用于 Firefox 0.8 等。
您认为这是一个好的解决方案,还是一种非标准的 hack,随时可能崩溃?
【问题讨论】:
-
感谢您的提琴!我自己尝试将此解决方案与父级上的
line-height设置结合使用,这将子菜单推得太远。减去line-height并添加padding有帮助,耶!
标签: css css-position