Home  >  Article  >  Web Front-end  >  css定位案例探讨(position属性详解)_html/css_WEB-ITnose

css定位案例探讨(position属性详解)_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 11:33:53986browse

简述

定位问题一直是新手学习css的一个难点,现在我将他们总结出来,希望对大家有帮助

position详解

在css中,通过position属性,配合top,right,left,buttom对元素进行定位
position属性有:static,relative,absolute,fixed四种,下面分别探讨

默认定位static

                    Document    

效果:

盒子一行一个,自动换行

相对定位relative

                    Document    

元素框偏移某个距离。元素仍保持其未定位前的形状,它原本所占的空间仍保留。

绝对定位absolute

                    Document    

元素脱离原来的位置,释放来的空间,相当于被独立出来了,此时,它所相对的位置是它position为relative的父级元素,如果没有,则相对于body定位

固定定位fixed

元素框的表现类似于将 position 设置为 absolute,不过它的位置始终相对于窗口,可以实现固定导航栏的效果

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn