동적 CSS? 정보
동적 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일 경우.. 인데요.
0
댓글 3개

익스와 비익스 브라우저만 구분해서 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]>
