ファンクション
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | //モバイル分岐 タブレット含まず function is_mobile(){ $useragents = array ( 'iPhone' , // iPhone 'iPod' , // iPod touch 'Android.*Mobile' , // 1.5+ Android *** Only mobile 'Windows.*Phone' , // *** Windows Phone 'dream' , // Pre 1.5 Android 'CUPCAKE' , // 1.5+ Android 'blackberry9500' , // Storm 'blackberry9530' , // Storm 'blackberry9520' , // Storm v2 'blackberry9550' , // Storm v2 'blackberry9800' , // Torch 'webOS' , // Palm Pre Experimental 'incognito' , // Other iPhone browser 'webmate' // Other iPhone browser ); $pattern = '/' .implode( '|' , $useragents ). '/i' ; return preg_match( $pattern , $_SERVER [ 'HTTP_USER_AGENT' ]); |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | //モバイル分岐 タブレット含む function is_mobile() { $useragents = array ( 'iPhone' , // iPhone 'iPod' , // iPod touch 'Android' , // 1.5+ Android 'dream' , // Pre 1.5 Android 'CUPCAKE' , // 1.5+ Android 'blackberry9500' , // Storm 'blackberry9530' , // Storm 'blackberry9520' , // Storm v2 'blackberry9550' , // Storm v2 'blackberry9800' , // Torch 'webOS' , // Palm Pre Experimental 'incognito' , // Other iPhone browser 'webmate' // Other iPhone browser ); $pattern = '/' .implode( '|' , $useragents ). '/i' ; return preg_match( $pattern , $_SERVER [ 'HTTP_USER_AGENT' ]); } |
ヘッダー
1 2 3 4 5 | <?php if (is_mobile()) : ?> <link href= "/css/mobile.css" rel= "stylesheet" type= "text/css" /> <?php else : ?> <?php endif ; ?> |
moble.css
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 | @charset "UTF-8" ; /* CSS Document */ /*font-size:100%は親要素mに依存 最も親か?? いや直上の指定してある親だ なにも親がしていしていなければ ボディー ボディーもしていなければ ブラウザ依存 */ .blog_con{ font-size : 120% !important } .blog_titel_min{ font-size : 100% !important } body{ font-size : 16px ;} /*.top_titel,*/ /*.top_sub_titel,*/ /*.top_sub_span,*/ .color_blue, .top_box p, .top_con p, .top_p, .jirei_sub_title { font-size : 150% !important } .set_day_all{ font-size : 150% !important } .set_day{ width : auto ; margin-right : 30px ;} .jirei_disp_con{ font-size : 100% !important } body #wp_page_numbers li a{ font-size : 300% !important ; padding : 30px !important ;} |
直で埋め込んであった改行削除コード
1 2 3 4 5 6 | <?php if (is_mobile()) : ?> <style type= "text/css" > .smap br { display:none; } </style> <?php else : ?><?php endif ; ?> |
事例ページなどをpで最適化し
pを150%などにした。
基本csss
1 2 3 4 | /*モバイル用 文字が大きくならない*/ body div{ max-height : 100% ; } |