css - 在与位置 :relative? 相同的声明中,属性 top、left、right、bottom 是合法的

标签 css

我知道您可以在 div 元素中声明 position:relative。然后,如果您在子 block 元素中声明 position:absolute,则可以使用 top、left、bottom 和 right 将该元素“相对”定位到声明为 的父元素position:relative

在我继承的 CSS 代码中,我在同一声明中看到了 position:relative 和 top 或 left 的组合。这是一个错误吗?如果是这样,为什么要使用它?

最佳答案

css top, left, right, bottom 适用于所有定位元素(即 position:static 除外)。

Example

关于css - 在与位置 :relative? 相同的声明中,属性 top、left、right、bottom 是合法的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26154381/

相关文章:

CSS Flip 跨浏览器功能

html - CSS div 不适应内容

HTML 文本覆盖图像

html - Bootstrap 选项卡 Pane 填充 100% 高度

css - 在 Google 文档中,在插入表格的位置上方和下方始终有一个空行?

c# - 为什么 css 样式不适用于 javascript 中的匹配行?

css - CSS 粘性页脚实现之间的区别?

css,禁用的 css 文件

javascript - iPad 和 iPhone 通用应用程序的不同 CSS 样式表

javascript - 使用 jQuery 切换伪元素