>  기사  >  웹 프론트엔드  >  CSS 텍스트 오버플로 속성을 사용하는 방법

CSS 텍스트 오버플로 속성을 사용하는 방법

青灯夜游
青灯夜游원래의
2019-05-29 16:58:392964검색

css text-overflow属性用于指定当文本溢出包含它的元素时,应该发生什么事情。所有主流浏览器都支持 text-overflow 属性。

CSS 텍스트 오버플로 속성을 사용하는 방법

css text-overflow属性怎么用?

text-overflow 属性规定当文本溢出包含元素时发生的事情。

语法:

text-overflow: clip|ellipsis|string;

属性值:

● clip:修剪文本。        

● ellipsis:显示省略符号来代表被修剪的文本。   

● string:使用给定的字符串来代表被修剪的文本。    

注释:所有主流浏览器都支持 text-overflow 属性。

css text-overflow属性 示例

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 
<style> 
div.test
{
white-space:nowrap; 
width:12em; 
overflow:hidden; 
border:1px solid #000000;
}
</style>
</head>
<body>
<p>以下 div 容器内的文本无法完全显示,可以看到它被裁剪了。</p>
<p>div 使用 "text-overflow:ellipsis":</p>
<div class="test" style="text-overflow:ellipsis;">This is some long text that will not fit in the box</div>
<p>div 使用 "text-overflow:clip":</p>
<div class="test" style="text-overflow:clip;">This is some long text that will not fit in the box</div>
<p>div 使用自定义字符串 "text-overflow: >>"(只在 Firefox 浏览器下有效):</p>
<div class="test" style="text-overflow:&#39;>>&#39;;">This is some long text that will not fit in the box</div>
</body>
</html>

效果图:

CSS 텍스트 오버플로 속성을 사용하는 방법

위 내용은 CSS 텍스트 오버플로 속성을 사용하는 방법의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.