본문 바로가기

CSS

text-overflow: ellipsis;

Div 동적으로 사이즈 변환할때 텍스트 영역 채우기


텍스트가 Div 값을 넘어갈때 말줄임 한다. 

css 에서 이런게 될줄은 생각도 못했는데...



코드 예

 

<!DOCTYPE html>

<html>

<head>

<style> 

div.a {

  white-space: nowrap; 

  width: 50px; 

  overflow: hidden;

  text-overflow: clip; 

  border: 1px solid #000000;

}


div.b {

  white-space: nowrap; 

  width: 50px; 

  overflow: hidden;

  text-overflow: ellipsis; 

  border: 1px solid #000000;

}


div.c {

  white-space: nowrap; 

  width: 50px; 

  overflow: hidden;

  text-overflow: "----"; 

  border: 1px solid #000000;

}

</style>

</head>

<body>


<h1>The text-overflow Property</h1>


<p>The following two divs contains a text that will not fit in the box.</p>


<h2>text-overflow: clip (default):</h2>

<div class="a">Hello world!</div>


<h2>text-overflow: ellipsis:</h2>

<div class="b">Hello world!</div>


<h2>text-overflow: "----" (user defined string):</h2>

<div class="c">Hello world!</div>


<p><strong>Note:</strong> The text-overflow: "<em>string</em>" only works in 

Firefox.</p>


</body>

</html>

 


발췌 : w3schools.com     https://www.w3schools.com/cssref/tryit.asp?filename=trycss3_text-overflow