Css 即使父元素是相对定位的,也可以相对于实体绝对定位元素吗?
我没有编辑HTML的权限,所以我只剩下一个边栏,我想相对定位,这样我就可以绝对定位其中的一个元素,但我也希望一个孩子的孩子相对于身体绝对定位,而不是边栏 可视示例:Css 即使父元素是相对定位的,也可以相对于实体绝对定位元素吗?,css,Css,我没有编辑HTML的权限,所以我只剩下一个边栏,我想相对定位,这样我就可以绝对定位其中的一个元素,但我也希望一个孩子的孩子相对于身体绝对定位,而不是边栏 可视示例: Sidebar (relative) | child (absolutely positioned in sidebar) | child (statically positioned) | | | | child of child (absolutely positioned relative to the body) /
Sidebar (relative)
| child (absolutely positioned in sidebar)
| child (statically positioned)
| | | | child of child (absolutely positioned relative to the body)
/Sidebar
不,不是用CSS。但你可以:
- 将负值用于
和左侧
顶部
- 可能使用JavaScript更改元素在DOM中的位置