這個網誌中的熱門文章
html viewport meta
html viewport meta 淺見及說明 web mobile 化已經是一個全球的局面,好像網站如果沒有做個 media query,都會羞的不敢見人。 神奇的地方是很多人都會在html head 處加上 viewport 這個 meta data,為了釐清實際的效用以及屬性,接下來將大略介紹 viewport-meta 說明屬性與應用。 屬性說明 W3C 協會定義 viewport meta 目前還屬於草案,意思就是有可能隨時修改,特別註記一下,此文於西元2012年3月28日撰寫,以下描述如有出入,以W3C 標準為主。 viewport 可以設定的屬性分別如下, width:可設定數值,或者指定為 device-width height:可設定數值,或者指定為 device-height initial-scale:第一次進入頁面的初始比例 minimum-scale:允許縮小最小比例 maximum-scale:允許放大最大比例 user-scalable:允許使用者縮放,1 or 0 (yes or no) 最初執行viewport meta加入如下 <meta name="viewport" content="width=device-width, initial-scale=1.0"> 編譯過程會轉化成如下的語意, @viewport { width: device-width; initial-scale: 1.0 } 基本說明 width=device-width 先提一下幾個注意的地方,首先在 viewport 裡面的 width 通常會看到設定為device-width ,主要是為了讓整個頁面寬度與手機可視寬度相同,如此就可以簡單相容於不同機型螢幕大小,如果這邊width 沒有設定的話,就會依照 html css 給予的 width 當作預設值。 因為解析度不同,device-width 有時候不一定是 view width ,所以在類似 iphone 4 高解析度機器上,device-width=320 ,可是實際解析度為 480,這時候就需要利用javascript 針對UA 下去做動態調整。 user-scalable 從屬性名稱來看就是...
Get latest google trends with php
Get latest google trends with php Here we come to the fact that if you want traffic to your website it would be good to create posts about the subjects that people search the most which will lead to more visitors and visitors are money. I needed an automated way to extract google trends on hourly bases and store in my database so I can then use them. Google does not provide API for this so here is a script that scrapes google feed and extracts the keywords. <?php $url = 'http://www.google.com/trends/hottrends/atom/feed?pn=p1'; $referrer = 'http://www.google.com'; $agent = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.8) Gecko/2009032609 Firefox/3.0.8'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HTTPPRO...
留言
張貼留言