多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
[TOC] # 浮动 ``` float: left;right; ``` ## 案例1:脱离文档流 ![](https://img.kancloud.cn/36/c8/36c8879d59746c7cffbef2ccf0107515_612x257.png) ## 案例2:制作导航栏 ![](https://img.kancloud.cn/4a/36/4a3648d5af2478cdd6547dfec5b74d0b_803x80.png) ## 选修 ### 1. 浮动元素的排列位置 > 与上一个块级元素有关 > 1. 如果上一元素浮动,则顶部对齐 > 2. 如果上一元素正常(块级),则底部对齐 ![](https://img.kancloud.cn/46/05/46055715767fe875037d9abee52ac806_995x323.png) ![](https://img.kancloud.cn/6d/cd/6dcdf5b8dd2e4dbcfea5c0ee890c8456_498x353.png) ### 2:清除浮动 ![](https://img.kancloud.cn/70/13/7013a2b486ada6670ebbf72c1a80750c_997x240.png) ![](https://img.kancloud.cn/94/69/9469e180a78ba592ce7003191662305a_283x255.png) # 定位 ``` position: static; /*默认原位置,无特殊效果*/ position: relative; /*不脱离文档流,默认原始位置,相对于原位置*/ position: absolute; /*脱离文档流,默认原始位置,相对于有特殊定位的父元素*/ position: fixed; /*脱离文档流,默认原始位置,相对于窗口*/ ``` ## 案例3:定位的四种方式 ![](https://img.kancloud.cn/a0/4f/a04f55e53fd397223be7e34b448a6d05_478x363.png) # display > 1. 块级元素/行内元素/行内块元素 > 2. 显示和隐藏 > 3. 可见与不可见visibility ``` visibility: hidden; visible; ``` ## 案例4:制作菜单 ![](https://img.kancloud.cn/84/03/84038d0f12562dc12ad45ee3a0786a65_420x200.gif) # 扩展:不可见文字 ``` <style type="text/css"> div:first-child{ display: none; } div:nth-child(2){ visibility: hidden; } div:nth-child(3){ color: rgba(0,0,0,0); } div:nth-child(4){ opacity: 0; } </style> ```