加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 资源网站 > 资源 > 正文

html – css位置绝对,顶部和底部都是

发布时间:2020-12-14 23:50:44 所属栏目:资源 来源:网络整理
导读:我使用的位置:绝对;在div上. fiddle 我的代码是: .ab { background: none repeat scroll 0 0 #FF0000; bottom: 0; height: 100px; left: 0; position: absolute; top: 0; width: 100px;} 我想知道为什么即使我指定底部也是最重要的:0? 顶部和底部之间是
我使用的位置:绝对;在div上.

fiddle

我的代码是:

.ab {
  background: none repeat scroll 0 0 #FF0000;
  bottom: 0;
  height: 100px;
  left: 0;
  position: absolute;
  top: 0;
  width: 100px;
}

我想知道为什么即使我指定底部也是最重要的:0?
顶部和底部之间是否有任何优先问题?或者是什么原因?

解决方法

来自Mozilla: https://developer.mozilla.org/en-US/docs/Web/CSS/top

When both top and bottom are specified,as long as height is unspecified,auto,or 100%,both top and bottom distances will be respected. Otherwise,if height is constrained in any way,the top property takes precedence and the bottom property is ignored.

在您的示例中,您已经声明了设置高度以及顶部和底部位置,因此顶部位置优先,底部被忽略(无论您在顶部和底部列出的顺序如何).

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读