CSS float 属性 - 左浮动



描述

float: left 属性将元素定位在其容器的左侧,允许文本和内联元素环绕它。

可能的值

  • left − 将元素定位在左侧。

应用于

所有 HTML 元素。

DOM 语法

float: left;

示例

以下示例显示此属性的效果:

<html>
<head>
<style>
   div {
      border: 2px solid #f0610e;
      padding: 5px;
      height: 160px;
      background-color: #86f00e;
   }
   .tutimg {
      float: left;
      border: 3px solid #f0610e;
      margin-right: 10px;
   }
</style>
</head>
<body>
   <div>
       <img class="tutimg" src="images/tutimg.png" width="150" height="150" />
       There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in
       some form, by injected humour, or randomised words which don't look even slightly believable. If you are
       going to use a passage of Lorem Ipsum, you need to be sure there isn't anything embarrassing hidden in the middle
       of text. All the Lorem Ipsum generators on the Internet tend to repeat predefined chunks as necessary, making
       this the first true generator on the Internet.
   </div>
</body>
</html>
广告