微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

CSS相对右(或底)几乎永远不会工作

我一直在编写CSS一段时间了.

我注意到了

<div style="position: relative; right: 20%; bottom: 20%;">some text</div>

从来没有工作!

相对定位将与左上和上部指定,但不在右/底.为什么?

一个快速解决方案是使用“绝对”,并以像素指定右/底,但我需要一个理由.

另外,如果我错了,纠正我无论外部容器是绝对还是相对位置,将容器的位置“相对”放置在容器的边界上,还是容器内部的元素总是被定位为“绝对”?

谢谢.

解决方法

Absolute vs. Relative – Explaining CSS Positioning

Relative positioning uses the same four positioning properties as absolute positioning. But instead of basing the position of the element upon the browser view port,it starts from where the element would be if it were still in the normal flow.

原文地址:https://www.jb51.cc/css/216459.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。