728x90

PHP 테이블에서 글자수가 너무 길어서 2줄로 보이거나 테이블 구조가 이상하게 보이는 증상이 있어서 찾아봤더니 mb_strimwidth 함수를 이용하면 편하게 글자수 줄임이 가능하다.


mb_strimwidth ( string $str , int $start , int $width [, string $trimmarker [, string $encoding ]] )

mb_strimwidth('텍스트','시작위치','끝위치',"끝에붙일말","언어코드");


사용 예제


mb_strimwidth("Hello World", 0, 10, "...");


echo "<td class='bl'>".mb_strimwidth($row['positionNM'],'0','18','...','utf-8')."</td>";


표의 셀에서 글자수가 길어서 글줄임 ... 으로 표시하기도 하지만

echo "<td class='bl' style='font-size:0.8vw'>".$row['userNM']."</td>";

와 같이 style='font-size:0.8vw' 를 사용하면 글자 크기를 줄여서 보여줄 수 있다.


https://stackoverflow.com/questions/16056591/font-scaling-based-on-width-of-container
에 나온 내용을 참고했다.
The values are:
    vw (% of the viewport width)
    vh (% of the viewport height)
    vi (1% of the viewport size in the direction of the root element's inline axis)
    vb (1% of the viewport size in the direction of the root element's block axis)
    vmin (the smaller of vw or vh)
    vmax (the larger or vw or vh)

1 v* is equal to 1% of the initial containing block.


나중에 살펴보려고 검색한 링크를 적어둔다.

Responsive fonts - auto-scaling root font-size

https://codepen.io/2kool2/pen/ZpLYYo


'Web 프로그램 > PHP 응용 및 활용' 카테고리의 다른 글

날짜 선택  (0) 2018.10.26
접속단말 및 IP주소  (0) 2018.06.11
PHP to JSP  (0) 2018.04.28
PHP Form 다중 체크박스 값 전달 및 POST  (0) 2018.04.02
PHP 배열 합집합, 교집합, 차집합, 대칭차집합  (0) 2018.04.01
블로그 이미지

Link2Me

,