CSS

[position] CSS - clear 속성 ★ - float 해제후 줄바꿈 (= 클리어속성, clear속성, 상속 X)

목차
  1. clear 예제 - float 해제 후, 줄바꿈
  2. clear 정의
  3. clear 구문
  4. clear 예제1 - P2는 P1 밑줄에, P3는 P2 옆에 위치
  5. clear 예제2 - none, left, right, both 속성값 효과 비교
  6. clear 예제3 - 예제2와 비교

 

clear 예제 - float 해제 후, 줄바꿈 

 

<style>

img {float: left;}

p.clear {clear: both;}

</style>


<img src="https://source.unsplash.com/random" width="100" height="132">

<p>홈짱닷컴 Homzzang.com</p>

<p class="clear">홈페이지 제작관리 유지보수 관리매뉴얼 제공 + 코딩교육</p>


결과보기

 

clear 정의

 
박스요소 띄울 위치 지정 속성인 float 기능 해제하고 줄 바꿈 여부 결정.
즉, 특정 요소의 좌우에 어떤 요소가 올 수 없도록 선택 지정하는 역할 함.
 


1.
기본값: none
상속여부: X
애니효과: 
CSS버전: CSS1
JS구문: object.style.clear="both"
 
2.
주요 최신 브라우저 모두 지원.
 

clear 구문

 
selector{clear: none|left|right|both|initial|inherit;}
 

[속성값]

none
float 속성을 해제하지 않음 (기본값)
 
left
왼쪽에 float 된 요소의 아랫줄에 위치 시킴.
 
right 
오른쪽에 float 된 요소의 아랫줄에 위치 시킴.
 
both
양쪽에 float 된 요소 모두의 아랫줄 위치 시킴. 
※ float 된 속성 줄바꿈할 때 both 속성값 자주 사용.
※ both 대신 all 사용해도 효과 나타남.
 
initial
이 속성의 기본값으로 설정.
 
inherit
부모요소 속성값 상속.
 
 

clear 예제1 - P2는 P1 밑줄에, P3는 P2 옆에 위치

 
<style>
div {width:100%; height:100px; border:1px solid red;}
p.p1 {float:left; widh:100px; padding-left:30px;}
p.p2 {float:left; widh:100px; padding-left:30px; clear:both;}
p.p3 {float:left; widh:100px; padding-left:30px;}
</style>

<div>
<p class=p1>홈짱닷컴 (homzzang.com)</p>
<p class=p2>홈페이지 무료 제작 강의</p>
<p class=p3>HTML CSS 알기 쉽게 강의</p>
</div>

clear 예제2 - none, left, right, both 속성값 효과 비교

 
<style>
.box1, .box2, .box3, .box4 {clear:both; margin-bottom:70px; width:720px; border:1px solid silver; overflow:auto;}
.redline {border-top:solid red;}

.box1 > .left,.box1 > .right,.box2 > .left,.box2 > .right,
.box3 > .left,.box3 > .right,.box4 > .left,.box4 > .right 
{background-color:#f8e1eb;width:100px; text-align:center;}
.left {float:left;}
.right {float:right}
</style>
 
 
<div class="box1"> 
    <div class='left' style="height:20px;">왼쪽</div>
    <div class='right' style="height:40px;">오른쪽</div>
    clear:none - 홈짱닷컴 글씨 아래 줄에 밑줄
    <br clear="none">
    <div class="redline"></div>
</div>

<div class="box2"> 
    <div class='left' style="height:20px;">왼쪽</div>
    <div class='right' style="height:40px;">오른쪽</div>
    clear:left - 왼쪽 float 된 1번 아래 줄에 위치
    <br clear="left">
    <div class="redline"></div>
</div>

<div class="box3"> 
    <div class='left' style="height:20px;">왼쪽</div>
    <div class='right' style="height:40px;">오른쪽</div>
    clear:right - 오른쪽쪽 float 된 2번 아래 줄에 위치
    <br clear="right">
    <div class="redline"></div>
</div>

<div class="box4"> 
    <div class='left' style="height:60px;">왼쪽</div>
    <div class='right' style="height:40px;">오른쪽</div>
    clear:both - 양쪽 모두의 아래 줄에 위치
    <br clear="both">
    <div class="redline"></div>
</div>
 
 

clear 예제3 - 예제2와 비교

<div style="border-top:solid red;"></div>는 1과 2와 동위의 줄에 위치하나,
홈짱닷컴 줄은 clear 속성에 의해 한칸 아래 위치
 
<style>
.box1, .box2, .box3, .box4 {clear:both; margin-bottom:70px; width:720px; border:1px solid silver; overflow:auto;}
.redline {border-top:solid red;}

.box1 > .left,.box1 > .right,.box2 > .left,.box2 > .right,
.box3 > .left,.box3 > .right,.box4 > .left,.box4 > .right 
{background-color:#f8e1eb;width:100px; text-align:center;}
.left {float:left;}
.right {float:right}
.text {width:400px;}
</style>
 
<div class="box1"> 
    <div class='left' style="height:20px;">왼쪽</div>
    <div class='right' style="height:40px;">오른쪽</div>
    <div class='text' style="float:right; clear:none;">
         홈짱닷컴 (homzzang.com) clear:none - 빨간 줄의 아래 줄에 위치
    </div>
    <div class="redline"></div>
</div>

<div class="box2"> 
    <div class='left' style="height:20px;">왼쪽</div>
    <div class='right' style="height:40px;">오른쪽</div>
    <div class='text' style="float:right; clear:left;">
         홈짱닷컴 (homzzang.com) clear:left - 왼쪽 1번의 아래 줄에 위치
    </div>
    <div class="redline"></div>
</div>

<div class="box3"> 
    <div class='left' style="height:20px;">왼쪽</div>
    <div class='right' style="height:40px;">오른쪽</div>
    <div class='text' style="float:right; clear:right;">
         홈짱닷컴 (homzzang.com) clear:right - 우측 2번 아래 줄에 위치
    </div>
    <div class="redline"></div>
</div>

<div class="box4"> 
    <div class='left' style="height:60px;">왼쪽</div>
    <div class='right' style="height:40px;">오른쪽</div>
    <div class='text' style="float:right; clear:both;">
         홈짱닷컴 (homzzang.com) clear:both - 양쪽의 아래 줄에 위치
    </div>
    <div class="redline"></div>
</div>
 
결과 보기


방문 감사합니다. (즐겨찾기 등록: Ctrl + D)

분류 제목
text CSS - letter-spacing 속성 ★ - 글자 간격 사이사이 띄우기 ( 텍스트사이띄우기 = 문자 간…
text CSS - line-height 속성 ★ - 텍스트라인높이 (= line-height속성 = 텍스트줄높이 =…
text CSS - text-align 속성 ★ - 텍스트정렬 (= text-align속성 = 텍스트얼라인속성)
text CSS - text-decoration 속성 ★ - 텍스트라인 꾸미기 (= 밑줄/밑선, 가운데줄/취소선, 윗…
text CSS - text-indent 속성 ★★ - 단락 첫줄 텍스트 들여쓰기 (= text-indent속성 = …
text CSS - text-transform 속성 - 텍스트 대소문자변환 (= text-transform속성 = 텍…
text CSS - word-spacing 속성 ★ - 텍스트 단어간 간격 (= 단어간격 = word-spacing…
text CSS - vertical-align 속성 ★ - 텍스트수직정렬 (= vertical-align속성 = 버티…
text CSS - white-space 속성 ★ - 공백처리/줄바꿈 지정 (= white-space속성 / 화이트스…
text CSS - unicode-bidi 속성 - 텍스트글자방향 (= unicode-bidi속성 = 유니코드비디속성…
list CSS - list-style 속성 ★ - 리스트 스타일 일괄 (= 리스트마커 = list-style속성 =…
list CSS - list-style-type 속성 ★ - 리스트 스타일 타입 (= 리스트 마커 종류 = 리스트스타…
list CSS - list-style-image 속성 - 리스트 스타일 이미지 (= 리스트 마커 이미지 = list…
list CSS - list-style-position 속성 ★ - 리스트 스타일 위치 (= 리스트 마커 위치 = …
box CSS - margin 속성 ★ - 바깥여백 (= margin속성 = 마진속성) ※ (margin병합 = 마…
6/33
목록
  • 채팅방
  • 필독
1. 채팅창 헤드에서 접속자 확인 2. 닉네임 클릭해 1:1 채팅 가능 3. 닉네임 클릭해 귓속말 가능 4. 닉네임 클릭해 호출하기 가능 5. 우하단 클릭해 환경 설정 가능 6. 의뢰글 작성 후 의뢰 상담 가능 7. 질문글 작성 후 질문 상담 가능 8. 채팅방에 개인정보 입력 금지 9. 채팅방에 광고 욕설 비방 금지
 홈  PC버전 로그인 일본어
웹디자인언어
서버관리언어
고급코딩언어
그누보드
제작의뢰
Q&A
커뮤니티 3
웹유틸
회원센터
홈짱 PC버전 로그인