gpt4 book ai didi

css - 位置 : absolute without setting top/left/bottom/right?

转载 作者:技术小花猫 更新时间:2023-10-29 10:12:07 24 4
gpt4 key购买 nike

案例#1:

我想在默认 WordPress 主题 ( http://twentyelevendemo.wordpress.com/ ) 中的标题中的照片上方放置一个 Logo

我的解决方案:在照片前添加标志,并在其上设置position: absolute设置任何top/left/bottom/right 属性:

http://jsfiddle.net/TsAJp/

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-cell 不支持position: relative,所以我唯一的解决方案是:http://jsfiddle.net/pCe49/

它适用于 IE6-7、Firefox1.5,不适用于 Firefox 0.8 等。

您认为这是一个好的解决方案,还是一个随时可能崩溃的非标准 hack?

最佳答案

标准通常说如果顶部/底部、左侧/右侧是自动的,则将它们默认为它们的position: static 值:

http://www.w3.org/TR/CSS2/visudet.html#abs-non-replaced-width

http://www.w3.org/TR/CSS2/visudet.html#abs-non-replaced-height

关于css - 位置 : absolute without setting top/left/bottom/right?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10243991/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com