CSS的4种定位方式比较

 

CSS有四种定位(Positioning)方法:Static,Relative, Absolute和Fixed

元素flow, overlap

 

相对参照物:

能否用offset(

top, left, bottom, right)参数

是否移出 normal flow

是否可以

overlap

备注

Static

 缺省的,
normal flow

忽略

No

 

 

Relative

its own normal position

No

Yes

常用作 Absolute元素的container

Fixed

browser  windows

Yes

Yes

ignore scrolling

Absolute

相对于

* 首个非static的父元素, (包括relative的),

* document body元素(如果没有非static元素的话)

Yes

Yes

 


偏移量(offset)的描述: /coordinate: top, bottom, left, and right

 

使用 max-width 替代 width 可以使浏览器更好地处理小窗口的情况。这点在移动设备上显得尤为重要,

移动浏览器对 fixed 的支持很差, tips见 :http://bradfrost.com/blog/mobile/fixed-position/


http://www.w3schools.com/css/css_display_visibility.asp
http://zh.learnlayout.com/margin-auto.html

 

* 搞定zIndex:'Auto' means that element gets z-index from its parent.

水涨船高, 后面的总会比他高(继承了!!!)

用图片美化按钮:

.{

    position: ;

    left:;

    top:;

    z-index: ;

    background: () ;

}

 

 Positioning, layout, coordinate and offset

转载于:https://www.cnblogs.com/GameEngine/p/6528753.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值