HTML DOM clear 속성은 부동 요소의 위치를 가져오거나 설정하는 데 사용됩니다. 요소를 다른 부동 요소 아래로 이동해야 하는지 여부를 지정하는 데 사용됩니다.
다음은 −
의 구문입니다.clear 속성 설정 -
object.style.clear='none|left|right|both|initial|inherit'
위의 속성은 다음과 같이 설명됩니다 -
| 값 | 설명 |
|---|---|
| 왼쪽 | 요소는 왼쪽에 떠 있지 않습니다. |
| 맞습니다 | 요소가 오른쪽에 떠 있지 않습니다. |
| 둘 다 | 요소는 왼쪽이나 오른쪽에 떠 있지 않습니다. |
| 없음 | 요소는 양쪽에 부동이며 이것이 기본값입니다. |
| 상속 | 상위 속성 값을 상속하려면 |
clear 속성의 예를 살펴보겠습니다. −
예시
<!DOCTYPE html>
<html>
<head>
<style>
img {
margin: 5px;
float: right;
clear: both;
border: 2px solid orange;
}
#DIV1{
clear:left;
}
</style>
<script>
function changeClear(){
document.getElementById("DIV1").style.clear="right";
document.getElementById("Sample").innerHTML="The div clear property is changed to right from left ";
}
</script>
</head>
<body>
<img src="https://www.tutorialspoint.com/qlikview/images/qlikview-mini-logo.jpg">
<div id="DIV1">This is sample text inside div. This is another line inside the div.Here is a div containing some random english text. This div is created to demonstrate clear property </div>
<p>Change the above div clear property by clicking the below button</p>
<button onclick="changeClear()">Change Clear</button>
<p id="Sample"></p>
</body>
</html> 출력

"변경 지우기"를 클릭하면 버튼 -
