前端開發代碼模版收錄

一、創建html

<!DOCTYPE html>
<html lang="zn-CN">
<head >
    <meta charset="UTF-8">
    <!--ie8~ie10  使用電腦上IE最新的文檔模式edge渲染頁面  ie11已放棄兼容模式,本身兼容已經很好了-->
    <meta http-equiv="x-ua-compatible" content="IE=edge">
    <!--移動端響應式設置-->
    <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1, minimum-scale=1, user-scalable=no">
    <!--SEO-->
    <meta name="keywords" content="購物,電商">
    <meta name="description" content="綜合購物平臺">
    <title>網頁標題</title>
    <link rel="stylesheet" href="css/normalize.css"/>
    <link rel="stylesheet" href="css/main.css"/>
</head>
<body>
<!--版本小於等於ie8處理-->
<!--[if lte IE 8]>
<p class="browserupgrade">您的瀏覽器版太舊了,請到 <a href="http://browsehappy.com">這裏</a>更新,以獲取最佳的體驗</p>
<![endif]-->
<header>
</header>
<div class="container">
</div>
<footer>
</footer>
</body>
</html>


二、基本css

    1、初始化頁面(normalize.css):http://down.51cto.com/data/2318760

    2、常用基本樣式、工具樣式 (pc上使用rem的話,需要考慮下css3屬性rem的兼容性)

/* ===================
    基本默認值
    ================== */
html{
    font-size: 125%;/* 瀏覽器默認16px*125%=20px,頁面中使用1rem=20px */
    color: #222;
}
::selection{
    background-color: #b3d4fc;
    text-shadow: none;
}/* 設置文字選中的顏色,以及是否有陰影 */

ul{
    margin: 0;
    padding: 0;
}
li{
    list-style: none;
}

/* =====================
    工具樣式
    ==================== */
.center-block{
    display: block;
    margin-left: auto;
    margin-right: auto;
}
.pull-right{
    float: right; !important;
}
.pull-left{
    float: left; !important;
}
.text-right{
    text-align: right; !important;
}
.text-left{
    text-align: left; !important;
}
.text-center{
    text-align: center; !important;
}
.hide{
    display: none; !important;
}
.show{
    display: block; !important;
}

.invisible{
    visibility: hidden;
}/* 不僅隱藏元素,而且不佔用空間 */

.text-hide{
    font: 0/0 a;
    color: transparent;
    text-shadow: none;
    background-color: transparent;
    border: 0;
}/* 隱藏文本 */

.clearfix:before,
.clearfix:after{
    content:"";
    display: table;
}/* 清除浮動1  使用:before可以防止本元素的頂部margin與上方元素的底部margin發生重疊*/

.clearfix:after{
    clear: both;
}/* 清除浮動2 */

/* ======================
    瀏覽器更新提示
    ===================== */
.browserupgrade{
    margin: 0;
    padding: 0.5rem;
    background: #cccccc;
}

/* ====================
    自定義頁面樣式
    =================== */
body{
    font-size: 0.6rem;
    font-family: normal normal,microsoft yahei,Arial,sans-serif;
    line-height: 1.5;
    background-color: #f7f7f7;
}
a{
    color: #666666;
    text-decoration: none;
}
a:hover,a:active{
    color: #0ae;
    text-decoration: underline;
}


三、移動端rem處理 (已1rem=30px爲例)

(function() {
  var iWidth = document.documentElement.getBoundingClientRect().width;
  iWidth = iWidth > 750 ? 750 : iWidth;
  document.getElementsByTagName('html')[0].style.fontSize = iWidth / 25 + 'px';
})();


附:

  1、顏色拾取器(美工必備屏幕顏色吸取器) http://down.51cto.com/data/2318767

  2、10個HTML5美化版複選框和單選框:http://www.html5tricks.com/10-pretty-checkbox-radiobox.html

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章