생활코딩

Coding Everybody

float

토픽 생활코딩 > 클라이언트 > CSS > CSS 사전

Summary

용기박스를 왼쪽 또는 오른쪽으로 이동하거나 이동하지 않음을 지정한다.

left | right | none | inherit
기본값 none
적용대상 position의 속성값이 static인 요소
상속 상속안됨
퍼센테이지 지정불가
미디어 Visual

Value

  • left : 박스를 왼쪽에 이동시킨다. 뒤에 나오는 내용들은 박스의 오른쪽 상단면부터 시작된다. [sample]
  • right : 박스를 오른쪽에 이동시킨다. 뒤에 나오는 내용은 박스의 왼쪽 상단면부터 시작된다. [sample]
  • none : 박스를 이동시키지 않는다.

Others

Here are the precise rules that govern the behavior of floats:

  1. The left outer edge of a left-floating box may not be to the left of the left edge of its containing block. An analogous rule holds for right-floating elements.
  2. If the current box is left-floating, and there are any left floating boxes generated by elements earlier in the source document, then for each such earlier box, either the left outer edge of the current box must be to the right of the right outer edge of the earlier box, or its top must be lower than the bottom of the earlier box. Analogous rules hold for right-floating boxes.
  3. The right outer edge of a left-floating box may not be to the right of the left outer edge of any right-floating box that is to the right of it. Analogous rules hold for right-floating elements.
  4. A floating box's outer top may not be higher than the top of its containing block.
  5. The outer top of a floating box may not be higher than the outer top of any block or floated box generated by an element earlier in the source document.
  6. The outer top of an element's floating box may not be higher than the top of any line-box containing a box generated by an element earlier in the source document.
  7. A left-floating box that has another left-floating box to its left may not have its right outer edge to the right of its containing block's right edge. (Loosely: a left float may not stick out at the right edge, unless it is already as far to the left as possible.) An analogous rule holds for right-floating elements.
  8. A floating box must be placed as high as possible.
  9. A left-floating box must be put as far to the left as possible, a right-floating box as far to the right as possible. A higher position is preferred over one that is further to the left/right.

댓글

댓글 본문
  1. 푸른하늘
    10일차 공부 감사합니다
  2. 후니
    일단 style 문법이...
    <div style="float: left; width: 100px; background-color: red; color: white;">
    라고 해 보면 잘 됩니다.
    대화보기
    • 코이코이
      float는 html 태그 안에 넣을수 있을가요 없을까요?

      <img src="http://" style: float-left />

      이렇게 했는데 먹히지를 않네요
    • Sung Gil Yun
      감사합니다.