참치캔

동적 CSS?

사용자의 OS와 브라우저에 따라 CSS를 달리해볼 필요가 있어서..
head.sub.php 에서 분기할 생각을 했다가..
구글 검색한 결과 어느 외국 블로그에선가 보고 해봤는데 됩니다.


- 시작 -
(1) head.sub.php 에서는 php로 된 CSS를 불러오고
<link rel="stylesheet" href="<?=$g4['path']?>/style.css.php" type="text/css">

(2) style.css.php의 내용은
<?
header("Content-Type: text/css");

$http_user_agent = $_SERVER['HTTP_USER_AGENT'];
$k_http_user_agent = strtolower($http_user_agent);

if ((preg_match("/windows nt 6\.0/", $k_http_user_agent) || preg_match("/windows nt 6\.1/", $k_http_user_agent)) && preg_match("/msie/", $k_http_user_agent)) {
?>
body, td, p, input, button, textarea, select, .c1 { font-family:나눔고딕,NanumGothic,맑은 고딕,Malgun Gothic,Tahoma,굴림; font-size:13px; color:#333333; }

이하 생략

 

<?
} else
 if (preg_match("/windows nt 5\.1/", $k_http_user_agent) && preg_match("/firefox/", $k_http_user_agent)) {
?>
/* 테스트 용 */
body, td, p, input, button, textarea, select, .c1 { font-family:나눔고딕,NanumGothic,맑은 고딕,Malgun Gothic,Tahoma,굴림; font-size:13px; color:#ff6600; }

이하 생략

 

<?
} else {
?>
body, td, p, input, button, textarea, select, .c1 { font-family:나눔고딕,NanumGothic,맑은 고딕,Malgun Gothic,Tahoma,굴림; font-size:13px; color:#333333; }

이하 생략


<?
}
?>
이런 식으로.. lib/visit.lib.php 를 참고해서 만들었습니다.

- 끝 -



if ((preg_match("/windows nt 6\.0/", $k_http_user_agent) || preg_match("/windows nt 6\.1/", $k_http_user_agent)) && preg_match("/msie/", $k_http_user_agent)) {

이 부분이 맞는 코드인지 확실히 모르겠네요. 알려주시면 감사~
Vista 또는 Win& 이면서 IE일 경우.. 인데요.

|

댓글 3개

문제점 지적 완전 환영~
os를 구분하시는 특별한 이유가 있으신가요?? ^^;;
익스와 비익스 브라우저만 구분해서 css를 적용하는건 어떨까요?


<!--[if IE 5]>
<link href="/css/layout_ie5.css" rel="stylesheet" type="text/css" />
<![endif]-->
<!--[if IE 6]>
<link href="/css/layout_ie6.css" rel="stylesheet" type="text/css" />
<![endif]-->
<!--[if IE 7]>
<link href="/css/layout_ie7.css" rel="stylesheet" type="text/css" />
<![endif]-->
<!--[if IE 8]>
<link href="/css/layout_ie8.css" rel="stylesheet" type="text/css" />
<![endif]-->
<![if !IE]>
<link href="/css/layout_nonie.css" rel="stylesheet" type="text/css" />
<![endif]>
이유는 웹폰트..
댓글을 작성하시려면 로그인이 필요합니다.

그누4 팁자료실

그누보드4와 관련된 팁을 여러분들과 함께 공유하세요. 나누면 즐거움이 커집니다.

+
제목 글쓴이 날짜 조회
16년 전 조회 4,923
16년 전 조회 9,091
16년 전 조회 7,067
16년 전 조회 7,263
16년 전 조회 5,108
16년 전 조회 4,466
16년 전 조회 8,940
16년 전 조회 3,057
16년 전 조회 6,427
16년 전 조회 4,718
16년 전 조회 5,091
16년 전 조회 1만
16년 전 조회 3,585
16년 전 조회 3,584
16년 전 조회 7,350
16년 전 조회 7,280
16년 전 조회 5,499
16년 전 조회 6,072
16년 전 조회 6,689
16년 전 조회 4,811