word-break, white-space : 줄바꿈 속성



word-break : break-all  상위 블록의 width를 넘어서게 되면 단어를 깨뜨려 줄을 바꾸게 된다

white-space: nowrap    줄바꿈 금지

white-space: pre         작성한 그대로 (pre태그)

white-space: pre-wrap  pre효과와 비슷하지만 지정한 영역을 넘어가지 않음

white-space: pre-line    pre-wrap효과와 비슷하지만 띄어쓰기 공백은 한칸만 표현



html)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" 
          content="width=device-width, height=device-height, 
                     minimum-scale=1.0, maximum-scale=1.0, initial-scale=1.0">
    <title>Insert title here</title>
    <style>
    div {
        width: 100%;
    }
    p {
        background: #CEFBC9;
    }
    
    /*
    word-break : break-all 상위 블록의 width를 넘어서게 되면 줄을 바꾸게 된다
    white-space: nowrap    줄바꿈 금지
    white-space: pre            작성한 그대로 (pre태그)
    white-space: pre-wrap  pre효과와 비슷하지만 지정한 영역을 넘어가지 않음
    white-space: pre-line  pre-wrap효과와 비슷하지만 띄어쓰기 공백은 한칸만 표현
    */
    p.word_break {
        word-break : break-all;
    }
    p.nowrap{
        white-space: nowrap;
    }
    p.pre {
        white-space: pre;
    }
    p.pre_wrap {
        white-space: pre-wrap;
    }
    p.pre_line {
        white-space: pre-line;
    }
    </style>
</head>
 
<body>
<div>
    <p class="word_break">이에 재판관 전원의 일치된 의견으로 주문을 선고합니다. 주문, 피청구인 대통령 박근혜를 파면한다.</p>
    <p class="nowrap">이에 재판관 전원의 일치된 의견으로 주문을 선고합니다. 주문, 피청구인 대통령 박근혜를 파면한다.</p>
    <p class="pre">이에 재판관 전원의 일치된 의견으로 주문을 선고합니다. 주문, 피청구인 대통령 박근혜를 파면한다.</p>
    <p class="pre_wrap">이에 재판관 전원의 일치된 의견으로 주문을 선고합니다. 주문, 피청구인 대통령 박근혜를 파면한다.</p>
    <p class="pre_line">이에 재판관 전원의 일치된 의견으로 주문을 선고합니다. 주문, 피청구인 대통령 박근혜를 파면한다.</p>
</div>
</body>
</html>
cs



결과

+ Recent posts