html - 将位置从静态更改为相对位置会使绝对跨度消失

标签 html css

我的页面中有两个不同的 span,一个是 absolute 位置,另一个是 relative 位置。 Plunker代码是here .

现在,我看到绝对定位的 div 被完全隐藏了,

enter image description here

但是当我将我的 relative-ly positioned span 更改为 static 位置时,absolute 位置 span 出现在顶部,

enter image description here

css-tricks说,

If you set position: relative; on an element but no other positioning attributes (top, left, bottom or right), it will no effect on it's positioning at all, it will be exactly as it would be if you left it as position: static;

如我所见,relativestatic 都不相同。 relativestatic 位置如何影响顶层显示的内容?

最佳答案

你有 absolute div 出现在 View 中,它只是你在相对类的跨度之后写了绝对类的跨度,所以绿色 block 在黑色 block 之上。如果你给 z-index:2; 绝对类那么你可以看到绝对类跨度

关于html - 将位置从静态更改为相对位置会使绝对跨度消失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36666695/

相关文章:

css - 即使类不存在,也包含 SASS mixin

jquery - 当屏幕较小时,有没有办法控制我的div在class =“row”内的垂直对齐方式

javascript - 如果 2 个单选按钮具有相同的值,则打开选择第一个单选按钮的页面

javascript - 从另一个页面获取 ElementById

javascript - 防止在 Angular 中按 Enter 键时提交表单

android - 移动网络浏览器上的 Thaana 字体

html - 根据 TD 或多或少的值在表的 td 上添加一个 css 类

sockets - Html5 Websockets - 在使用 websockets 之前我应该​​了解套接字

javascript - 作为 jQuery DOM 操作结果的 CSS 转换

CSS mozilla 过渡不起作用