Position 属性工作原理
- Absolute 使元素相对最近的 positioned 祖先元素定位; 否则相对
viewport
(broswer window)定位; 脱离 page flow. - Relative 相对自身原本的位置定位; 不脱离 page flow, 在原本位置留下空白; 更多用于包含absolutely positioned 元素.
- Fixed 相对
viewport
定位; 脱离 page flow. - static Default.
- 元素的层次
z-index: 3;
Make a element above or beneath others. 隐藏页面部分
visibility: hidden | visible;
显示/隐藏元素, 不脱离流, 留空白.opacity: 0 .. 1;
不脱离流, 留空白; 可用于动画.display: .. | none;
脱离流, 空白被其他元素填充.
display: none;
skipvisibility
property;display: none;
同position: abosulte; visibility: hidden;
效果相同.css tooltip:
http://www.menucool.com/tooltip/css3-tooltip
http://qtip2.com//123456789101112131415161718192021222324252627282930/* 1. Create the HTML for the image and caption. */<figure class="hat"><img src="hat.jpg" width="100" height="100"><figcaption>A picture of a hat</figcaption></figure>/* 2. Postion the Caption. */.hat {postion: relative;width: 100px;height: 100px;}.hat figcaption {display: none; /* 3. Hide the caption *//* or* opacity: 0;* transition: opacity .5s ease-in; */postion: absolute;bottom: 0;left: 0;right: 0;background-color: white;}/* 4. Make the caption appear when a visitor mouses over the image. */.hat:hover figcaption {display: block;/* or* opacity: 1; */}
强大的定位策略
- 元素内定位 -
relative
containingabsolute
- 超出盒子 - 使用负数
margin
使元素伸出(poke out of)其容器 - 固定 (fixed) 定位 - 固定navigation panel, search box, site logo, sidebar…