---
title: "[CSS] 学习笔记float"
author: "iandaicsu"
date: "2013-09-02T15:56:47Z"
tags: []
categories: ["Web前端"]
slug: "css-float"
draft: false
lastmod: "2013-09-02T15:56:47Z"
id: 1935442
url: "https://iandaicsu.iteye.com/blog/1935442"
---

**float 属性定义元素在哪个方向浮动。**

 

 

**float主要的用途：**

**1 图片周围包围文字 （类似于word编辑中得图片浮动效果，除了图片本身占据的位置用来显示，其他位置都被其他元素占据了）**

**2 浮动可用于创建全部网页布局，例如sidebar** 

 

 

 

**float造成的效果：**

**1 自身向左（右）浮动**

**2 因为自身的浮动，导致下面一行的元素跳到上面一行。**

**3 要消除对下面一行的影响，要使用 div { clear: both; }** 

 

 

**代码示例： side bar and float**

https://tutsplus.com/lesson/floats-and-a-simple-layout/

 

**参考链接：**

CSS浮动属性Float详解    http://www.mymickey.org/?p=391