본문 바로가기
Frontend/CSS

[CSS] Text '...' 처리, 개행 처리 - ellipsis, wrap

by kkaboo 2023. 12. 18.
728x90

CSS에서 말줄임 처리하는 법은 다음과 같다.

overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;

 

 

CSS에서 개행 처리 하는 법은 다음과 같다.

white-space: wrap;
word-break: break-all;

 

Text '...' 처리, 개행 처리

예시코드

<html>
    <head>
        <title>Page Title</title>
    </head>
  <style>
    .s1 {
      border: 1px solid #ddd;
      background-color: #f8f9fb; 
      font-family: Noto Sans KR;
      padding: 1px 3px;
      width: 200px;
    }
  </style>
<body>
  <div class="s1" 
       style="overflow: hidden;
              white-space: nowrap;
              text-overflow: ellipsis;
              word-break: break-all;">
    <span>말줄임 표시 테스트 말줄임 표시 테스트</span>
  </div>
  <div style="height: 10px;"></div>
  <div class="s1" 
       style="white-space: wrap;
              word-break: break-all;">
    <span>개행 테스트 개행 테스트 개행 테스트</span>
  </div>
</body>
</html>

 

결과

728x90