textOverflow 사용 텍스트 오버플로 문제에 대응하는 속성입니다. 텍스트가 포함 요소를 오버플로하는 경우 줄임표를 추가합니다.
예시
다음 코드를 실행하여 텍스트가 JavaScript로 포함된 요소를 오버플로할 때 수행할 작업을 배울 수 있습니다. -
<!DOCTYPE html>
<html>
<head>
<style>
#myID {
border: 2px solid blue;
background-color: gray;
overflow: hidden;
text-overflow: visible;
width: 200px;
white-space: nowrap;
}
</style>
</head>
<body>
<button onclick = "display()"> Click </button>
<div id = "myID">
This is Demo Text! This is Demo Text! This is Demo Text!<br>
This is Demo Text! This is Demo Text! This is Demo Text!<br>
This is Demo Text! This is Demo Text! This is Demo Text!<br>
This is Demo Text! This is Demo Text! This is Demo Text!<br>
</div>
<script>
function display() {
document.getElementById("myID").style.textOverflow = "ellipsis";
}
</script>
</body>
</html>