CSS常用但又很容易忘記的語法

[HTML][PHP] 強制使用者重新整理 與 清除cache
每次在設計網頁時,常見到的網頁更新了~但是客戶看網頁的時候還是看到舊版的網頁,為了避免跟客戶溝通個老半天,所以我們可以將網頁加上一段語法讓網頁不被暫存,這樣每次看到的就會是最新的資訊了~也可以免除客戶老是抱怨要去清除暫存檔的麻煩。 有需要者,請把

<meta http-equiv="pragma" content="no-cache">

加在網頁的<head>這裡</head>就可以囉

如果網頁裡面有兩個以上的 frame (框架頁) ,有時候即便網頁設計師改變了框架頁中的圖片,但少數使用者,仍然會因為快取的關係而顯示舊的圖片,這時候,我們就必須強制清除他們的快取後重新整理網頁...

PHP 程式碼:(清cache)
header("Expires: Mon, 26 Jul 1990 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");

HTML 程式碼:(重新整理)
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="pragma" content="no-cache">

<meta http-equiv="expires" content="0">



Google 的 CDN
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>


input欄位消除圓角陰影,包含手機

input{-moz-border-radius: 0px; -webkit-border-radius: 0px; border-radius: 0px; -webkit-box-shadow:  0px inset;-moz-box-shadow:  0px inset; box-shadow:  0px inset; -webkit-appearance:none;}


FACEBOOK share image size
https://developers.facebook.com/docs/sharing/best-practices?locale=zh_TW#images

4. Optimize your image sizes to generate great previews
Use images that are at least 1200 x 630 pixels for the best display on high resolution devices. At the minimum, you should use images that are 600 x 315 pixels to display link page posts with larger images.


線上RWD產生器
http://www.lifeishao.com/rwdwire/

facebook 圖片規範
https://www.facebook.com/help/492441920771107/


GA Click
https://developers.google.com/analytics/devguides/collection/analyticsjs/events


Easing函數
http://easings.net/zh-tw

youtube api
http://css-tricks.com/play-button-youtube-and-vimeo-api/


做loading gif
http://www.ajaxload.info/

jquery-plugins
http://jquery-plugins.net/
http://tympanus.net/codrops/

刷新網頁範例
http://jun1986.iteye.com/blog/1176909

Google Fonts
http://www.google.com/fonts

CSS3產生器
http://www.css3maker.com/box-shadow.html

Google Maps JavaScript API v3
https://developers.google.com/maps/documentation/javascript/examples/?hl=zh-tw
設定精靈
http://gmaps-samples-v3.googlecode.com/svn/trunk/styledmaps/wizard/index.html
Google Maps 顏色設定
https://developers.google.com/maps/documentation/javascript/styling?hl=zh-tw

google網站管理員工具
https://www.google.com/webmasters/tools
Google search產生器
https://www.google.com/cse/create/new
建立sitemap工具網站
http://www.xml-sitemaps.com/


QR code產生器
http://azonmobile.com/qrcode-generator

TweenMax
http://www.greensock.com/jump-start-js/#stagger

jQuery Easing Plugin
http://gsgd.co.uk/sandbox/jquery/easing/

w3school
http://www.w3school.com.cn/index.html



/*初始化所有margin/padding影響的寬*//* 會影響fancybox的寬,要慎用 */
*{
box-sizing:border-box;
-moz-box-sizing:border-box; /* Firefox */
-webkit-box-sizing:border-box; /* Safari */
}



alert
alert('h1 is here!');


常用animate
$('.cad_girl1').delay(0).animate({left: 230}, 800, 'easeOutExpo');
$('.cad_time').delay(0).animate({right: 345}, 800, 'easeOutElastic');

meta viewport設定
手機版
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; minimum-scale=1.0;"/> 
電腦版
<meta name="viewport" content="width=1100">


偽裝click的2種寫法
1. href
$('a[href="#0"]').trigger('click');
2. child
$('pagination li:first-child').trigger('click');


slides.min.jquery.js參數
http://archive.slidesjs.com/

preload(boolean):是否預加載圖片,默認值為false。
preloadImage(string):預加載圖片的位置,默認值在"/img/loading.gif"。
slideSpeed:滑動速度,默認350毫秒。
play:一張Slide的停留時間。
pause:按下下一張、上一張的響應時間。
hoverPause:鼠標懸浮時暫停播放。




<span style="text-transform:uppercase;">Good Morning Piter.</span><br><!--定義所有字母均為大寫-->
<span style="text-transform:lowercase;">Good Morning Piter.</span><br><!--定義所有字母均為小寫-->
<span style="text-transform:capitalize;">Good Morning Piter.</span><!--定義單字的第一個字母大寫,其他字母小寫-->

map 的 area 点击在IE下出现虚框
white-space: nowrap;

上標字
vertical-align: super; 
下標字
vertical-align: sub; 


強制不換行
white-space: nowrap;

最前及最後
:first-child
:last-child

CSS :after 伪元素
:after {content:url(/i/w3school_logo_white.gif)}

隱藏li連結文字
text-indent:-9999px; 

文字平均齊尾
text-align:justify;

輸入框沒有外光暈
outline: none;

命令物件出現手指游標
cursor:pointer;

消除影像地圖按下後產生的連結虛線框
<img src="http://img.minwt.com/img/Content/noimg.jpg" hidefocus="true"/>

iframe透明背景
iframe.htm
<iframe src="SourcePage.htm" allowtransparency="true"></iframe>
SourcePage.htm 加在<body …..之後
style="background-color:transparent"

清除div結尾之前物件浮動
div/class name:after{visibility: hidden; display: block; font-size: 0; content: " "; clear: both; height: 0; }

list-style-type 属性
cjk-ideographic 中文一二三
decimal 數字
decimal-leading-zero 0開頭數字
disc 實心圓
circle 空心圓
square 方塊
lower-alpha 小寫英文
upper-alpha 大寫英文


隱藏所有捲軸
<body scroll="no">

隱藏橫軸
body{ overflow-x:hidden;

隱藏縱軸
body{ overflow-y:hidden;

捲軸置於左邊
<html dir="rtl">

物件外面包框(顏色/粗細/樣式)
border:#ccc 2px solid;

內容不縮放
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0" />

分享按鈕-Facebook
javascript: void(window.open('http://www.facebook.com/share.php?u='.concat(encodeURIComponent(location.href)) ));

分享按鈕-Twitter
javascript: void(window.open('http://twitter.com/home/?status=' .concat(encodeURIComponent(document.title)) .concat(' ') .concat(encodeURIComponent(location.href))));

分享按鈕-Plurk
javascript: void(window.open('http://www.plurk.com/?qualifier=shares&status=' .concat(encodeURIComponent(location.href)) .concat(' ') .concat('(') .concat(encodeURIComponent(document.title)) .concat(')')));

崁入google中文字型庫
html
<!-- Google Fonts script loader (for Droid Sans) -->
<link href='http://fonts.googleapis.com/css?family=Droid+Sans' rel='stylesheet' type='text/css'>
css
font-family:'Helvetica W01 Light', Helvetica, Arial, "微軟正黑體","Microsoft Jhenghei",sans-serif;

PHP 程式碼:(清cache)
header("Expires: Mon, 26 Jul 1990 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");

HTML 程式碼:(重新整理清cache)
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="expires" content="0">


符號表

1全形標點,、。.•;:?!︰…‥﹐﹑﹒·﹔﹕﹖﹗|–︱—︳╴︴﹏﹏
2各類括弧()︵︶{}︷︸〔〕︹︺【】︻︼《》︽︾〈〉^﹀「」﹁﹂『』﹃﹄﹙﹚﹛﹜﹝﹞`'“"〝〞‵′
3一般符號#&*※§〃○●△◎☆★◇◆□■▽▼㊣℅¯ ̄_ˍ﹉﹊﹍﹎﹋﹌﹟﹠﹡
4數學符號+-×÷±√<>=≦≧≠∞≒≡﹢﹣﹤﹥﹦~∩∪⊥∠∟⊿㏒㏑∫∮∵∴
5方向符號♀♂♁☉↑↓←→↖↗↙↘∥∣/\∕﹨
6單位符號$¥〒¢£%@℃℉€﹩﹪﹫㏕㎜㎝㎞㏎㎡㎎㎏㏄°兙兛兞兝兡兣嗧瓩糎
7圖表符號▁▂▃▄▅▆▇█▏▎▍▌▋▊▉┼┴┬┤├▔─│▕┌┐└┘╭╮╰╯═╞╪╡◢◣◥◤╱╲╳
8羅馬數字ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩ〡〢〣〤〥〦〧〨〩十卄卅
9希臘字母ΑΒΓΔΕΖΗΘΙΛΜΝΞΟΠΡΣΤΥΦΧΨΩαβγδεζηθικλμνξοπρστυφχψω
0注音符號ㄅㄆㄇㄈㄉㄊㄋㄌㄍㄎㄏㄐㄑㄒㄓㄔㄕㄖㄗㄘㄙㄚㄛㄜㄝㄞㄟㄠㄡㄢㄣㄤㄥㄦㄧㄨㄩ˙ˉˊˇˋ
® © ™


jQuery 捲軸數值
$(function(){
    $(window).scroll(function () {
        var scrollVal = $(this).scrollTop();
        $("數值容器").text(scrollVal);
    });
});

判斷觸發
if(scrollVal > 150){
  // 如果滾動的物件捲動 > 150 則觸發指定的動作。
}




fancybox Method
$.fancybox.showActivity =Shows loading animation
$.fancybox.hideActivity =Hides loading animation
$.fancybox.next =Displays the next gallery item
$.fancybox.prev =Displays the previous gallery item
$.fancybox.pos =Displays item by index from gallery
$.fancybox.cancel =Cancels loading content
$.fancybox.close =Hides FancyBox 
                           =Within an iframe use - parent.$.fancybox.close();
$.fancybox.resize =Auto-resizes FancyBox height to match height of content
$.fancybox.center =Centers FancyBox in viewport


對象屬性
document.title //設置文檔標題等價於HTML的title標籤
document.bgColor //設置頁面背景色
document.fgColor //設置前景色(文本顏色)
document.linkColor //未點擊過的鏈接顏色
document.alinkColor //激活鏈接(焦點在此鏈接上)的顏色
document.vlinkColor //已點擊過的鏈接顏色
document.URL //設置URL屬性從而在同一窗口打開另一網頁
document.fileCreatedDate //文件建立日期,只讀屬性
document.fileModifiedDate //文件修改日期,只讀屬性
document.fileSize //文件大小,只讀屬性
document.cookie //設置和讀出cookie
document.charset //設置字符集 簡體中文:gb2312
———————————————————————
常用對象方法
document.write() //動態向頁面寫入內容
document.createElement(Tag) //創建一個html標籤對象
document.getElementById(ID) //獲得指定ID值的對象
document.getElementsByName(Name) //獲得指定Name值的對象
document.body.appendChild(oTag)
———————————————————————

body-主體子對象
document.body //指定文檔主體的開始和結束等價於body>/body>
document.body.bgColor //設置或獲取對象後面的背景顏色
document.body.link //未點擊過的鏈接顏色
document.body.alink //激活鏈接(焦點在此鏈接上)的顏色
document.body.vlink //已點擊過的鏈接顏色
document.body.text //文本色
document.body.innerText //設置body>…/body>之間的文本
document.body.innerHTML //設置body>…/body>之間的HTML代碼
document.body.topMargin //頁面上邊距
document.body.leftMargin //頁面左邊距
document.body.rightMargin //頁面右邊距
document.body.bottomMargin //頁面下邊距
document.body.background //背景圖片

document.body.appendChild(oTag) //動態生成一個HTML對象

常用對象事件
document.body.onclick=」func()」 //鼠標指針單擊對象是觸發
document.body.onmouseover=」func()」 //鼠標指針移到對象時觸發
document.body.onmouseout=」func()」 //鼠標指針移出對象時觸發
———————————————————————
location-位置子對象

document.location.hash // #號後的部分
document.location.host // 域名+端口號
document.location.hostname // 域名
document.location.href // 完整URL
document.location.pathname // 目錄部分
document.location.port // 端口號
document.location.protocol // 網絡協議(http:)
document.location.search // ?號後的部分

documeny.location.reload() //刷新網頁
document.location.reload(URL) //打開新的網頁
document.location.assign(URL) //打開新的網頁
document.location.replace(URL) //打開新的網頁
———————————————————————
selection-選區子對象
document.selection
———————————————————————

images集合(頁面中的圖像)

a)通過集合引用
document.images //對應頁面上的img標籤
document.images.length //對應頁面上img標籤的個數
document.images[0] //第1個img標籤
document.images[i] //第i-1個img標籤

b)通過nane屬性直接引用
img name=」oImage」
document.images.oImage //document.images.name屬性

c)引用圖片的src屬性
document.images.oImage.src //document.images.name屬性.src

d)創建一個圖像
var oImage
oImage = new Image()
document.images.oImage.src=」1.jpg」
同時在頁面上建立一個img /標籤與之對應就可以顯示

———————————————————————-

forms集合(頁面中的表單)

a)通過集合引用
document.forms //對應頁面上的form標籤
document.forms.length //對應頁面上/formform標籤的個數
document.forms[0] //第1個/formform標籤
document.forms[i] //第i-1個/formform標籤
document.forms[i].length //第i-1個/formform中的控件數
document.forms[i].elements[j] //第i-1個/formform中第j-1個控件

b)通過標籤name屬性直接引用
/formform name=」Myform」>input name=」myctrl」/>/form
document.Myform.myctrl //document.表單名.控件名

c)訪問表單的屬性
document.forms[i].name //對應form name>屬性
document.forms[i].action //對應/formform action>屬性
document.forms[i].encoding //對應/formform enctype>屬性
document.forms[i].target //對應/formform target>屬性

document.forms[i].appendChild(oTag) //動態插入一個控件
document.all.oDiv //引用圖層oDiv
document.all.oDiv.style.display=」" //圖層設置為可視
document.all.oDiv.style.display=」none」 //圖層設置為隱藏
document.getElementId(」oDiv」) //通過getElementId引用對象
document.getElementId(」oDiv」).style=」"
document.getElementId(」oDiv」).display=」none」
/*document.all表示document中所有對象的集合
只有ie支持此屬性,因此也用來判斷瀏覽器的種類*/

圖層對象的4個屬性
document.getElementById(」ID」).innerText //動態輸出文本
document.getElementById(」ID」).innerHTML //動態輸出HTML
document.getElementById(」ID」).outerText //同innerText
document.getElementById(」ID」).outerHTML //同innerHTML



LINE
<a href="http://line.naver.jp/R/msg/text/?文字 快上:http://"><img src="image/line_icon.png"></a>


Facebook (官方小工具)

<!--Facebook分享按鈕(純HTML語法)-->
<a target="_blank" href="http://www.facebook.com/share.php?u=分享網址">
<img title="分享到臉書!" src="圖片網址" border="0" width="20" /></a>
 
<!--Facebook分享按鈕(JavaScript語法)-->
<a href="javascript: void(window.open('http://www.facebook.com/share.php?u='.concat(encodeURIComponent(location.href)) ));">
<img title="分享到臉書!" src="圖片網址" border="0" width="20" /></a>
 
<!--Facebook分享按鈕(WordPress參考語法)-->
<a target="_blank" href="http://www.facebook.com/share.php?u=<?php the_permalink(); ?>">
<img title="分享到臉書!" src="圖片網址" border="0" width="20" /></a>





Plurk
<!--Plurk分享按鈕(純HTML語法)-->
<a target="_blank" href="http://plurk.com/?qualifier=shares&status=[分享] 分享網址 (網址標題)">
<img title="分享到噗浪!" src="圖片網址" border="0" width="20" /></a>
 
<!--Plurk分享按鈕(JavaScript語法)-->
<a href="javascript: void(window.open('http://www.plurk.com/?qualifier=shares&status=' .concat(encodeURIComponent(location.href)) .concat(' ') .concat('&#40;') .concat(encodeURIComponent(document.title)) .concat('&#41;')));">
<img title="分享到噗浪!" src="圖片網址" border="0" width="20" /></a>
 
<!--Plurk分享按鈕(WordPress參考語法)-->
<a target="_blank" href="http://plurk.com/?qualifier=shares&status=[分享] <?php the_permalink(); ?> (<?php the_title(); ?>)">
<img title="分享到噗浪!" src="圖片網址" border="0" width="20" /></a>


Twitter (官方小工具)
<!--Twitter分享按鈕(純HTML語法)-->
<a target="_blank" href="http://twitter.com/home/?status=網址標題 分享網址">
<img title="分享到推特!" src="圖片網址" border="0" width="20" /></a>
 
<!--Twitter分享按鈕(JavaScript語法)-->
<a href="javascript: void(window.open('http://twitter.com/home/?status='.concat(encodeURIComponent(document.title)) .concat(' ') .concat(encodeURIComponent(location.href))));">
<img title="分享到推特!" src="圖片網址" border="0" width="20" /></a>
 
<!--Twitter分享按鈕(WordPress參考語法)-->
<a target="_blank" href="http://twitter.com/home/?status=<?php the_title(); ?> <?php the_permalink(); ?>">
<img title="分享到推特!" src="圖片網址" border="0" width="20" /></a>


新浪微博 (官方小工具)
<!--微博分享按鈕(純HTML語法)-->
<a target="_blank" href="http://v.t.sina.com.cn/share/share.php?title=網址標題&url=分享網址">
<img title="分享到微博!" src="圖片網址" border="0" width="20" /></a>
 
<!--微博分享按鈕(JavaScript語法)-->
<a href="javascript:(function(){window.open('http://v.t.sina.com.cn/share/share.php?title='+encodeURIComponent(document.title)+'&url='+encodeURIComponent(location.href)+'&source=bookmark','_blank','width=450,height=400');})()">
<img title="分享到微博!" src="圖片網址" border="0" width="20" /></a>
 
<!--微博分享按鈕(WordPress參考語法)-->
<a target="_blank" href="http://v.t.sina.com.cn/share/share.php?title=<?php the_title(); ?>&url=<?php the_permalink(); ?>">
<img title="分享到微博!" src="圖片網址" border="0" width="20" /></a>


Google+ (官方小工具) (2012.04.29 更新)
Google+的社群按鈕有分成+1(推文)和分享。+1的意思是"推薦"這篇文章,類似facebook按"讚"的意思,會顯示在推文者個人資料裡面,但是不一定會被分享到訊息列(塗鴉牆)上。而分享就是直接發佈到訊息列上,讓朋友們可以互相交流。兩者據說都會被google列入搜尋排名的考量因素中,所以二個按鈕最好都要使用。
+1的按鈕可以從官方工具選擇樣式後,直接貼上語法即可。如果要指定網頁(例如首頁),讓 +1 的按鈕不會隨網址變動而改變的話(如本站選單上的 +1),可以選擇「進階選項」輸入「+1 的網址」即可。
<!--Google+分享按鈕(純HTML語法)-->
<a target="_blank" href="https://plus.google.com/share?url=分享網址">
<img title="分享到Google+!" src="https://www.gstatic.com/images/icons/gplus-32.png" border="0" width="20" /></a>
 
<!--Google+分享按鈕(JavaScript語法)-->
<a href="javascript: void(window.open('https://plus.google.com/share?url='.concat(encodeURIComponent(location.href)), '', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=600,width=600'));">
<img title="分享到Google+!" src="https://www.gstatic.com/images/icons/gplus-32.png" border="0" width="20" /></a>
 
<!--Google+分享按鈕(WordPress參考語法)-->
<a target="_blank" href="https://plus.google.com/share?url=<?php the_permalink(); ?>" onclick="javascript:window.open(this.href, '', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=600,width=600');return false;">
<img title="分享到Google+!" alt="Share on Google+" src="https://www.gstatic.com/images/icons/gplus-32.png" border="0" width="20" /></a>
Pinterest
<a href="javascript: void(window.open('http://pinterest.com/pin/create/button/?url='.concat(encodeURIComponent(location.href))));"><li calss="pin" style="background-color:#CC2028"><img src="images/pin.png"></li></a>

留言