CSS 公用樣式

來源:互聯網
上載者:User

標籤:.class   letter   oom   table   comment   class   normal   field   lis   

common.css(公用組件樣式) 
layout.css(當前頁面樣式)

清除全站所有頁面的瀏覽器預設樣式,保證在初始樣式在所有瀏覽器下一致。

common.css(公用組件樣式)

一般一個網站所有頁面頭部、底部樣式都是一致的,而且很長時間不會有大的改變,改變的大概就是產品、運營的經常需要添加、去掉某些入口的需求,要保證全站所有頁面頭部一次替換生效,只要把標頭檔,已經對應的樣式一發,馬上生效,很快就有響應。

比如翻頁、表單(輸入框、按鈕)等樣式也是全站統一的,把這些樣式都放到common.css裡面,如果哪天所有的按鈕樣式要變更,一次替換就成功了。

layout.css(當前頁面樣式)

公用組件以外的所有樣式都寫到這個樣式檔案裡面,並且保證一個頁面一個獨立樣式,頁面html和css寫法要模組化,保證迅速響應項目頻繁的迭代。

為什麼要保證一個頁面一個獨立樣式,而且要模組化,肯定有朋友和我有過一樣的經曆,修改一行樣式代碼,整個頁面甚至N個頁面都會受影響,搞了半天還不知道哪裡出了問題,返回到修改前的版本,就沒問題了。終於找到原因了,卻不能改以前的樣式,更不能刪除,只能增加,時間一長,css樣式檔案越來越大,最後是不堪重負,整個頁面代碼只能重寫。

其實global.css和common.css也可以合并到一個檔案,畢竟格式化樣式也就那麼幾十行代碼,而且格式化樣式、頭部、底部樣式每個頁面都會用到。

這樣每個頁面就只有2個樣式:

common.css 
layout.css 
如果common.css裡面組件太多,而且很多組件也不是常用的,也可以像下面這樣做:

heads.css(格式話樣式、頭部、底部) 
common.css(公用組件樣式) 
layout.css(當前頁面樣式) 
一般情況下也只有2個樣式,當需要用到組件的時候才去link組件樣式,也不會有太多問題。

最後,不要把什麼東西都往組件樣式裡面塞,有寫東西寧願每個頁面重複拷貝也不要塞到組件樣式裡面去。某一天,你會發現這個組件樣式大得讓你可怕,而且很多都是無用的。

/***********通用基本類1************/

/*格式化樣式*/
body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,fieldset,input,textarea,p,blockquote,th,td {margin:0;padding:0;} 
table {border-collapse:collapse;border-spacing:0;} 
fieldset,img {border:0} 
address,caption,cite,code,dfn,em,strong,th,var {font-style:normal;font-weight:normal} 
ol,ul {list-style:none} 
caption,th {text-align:left} 
h1,h2,h3,h4,h5,h6 {font-size:100%;font-weight:normal} 
q:before,q:after {content:‘‘} 
abbr,acronym { border:0}

/*文字排版、顏色*/
.f12{font-size:12px}
.f13{font-size:13px}
.f14{font-size:14px}
.f16{font-size:16px}
.f20{font-size:20px}
.fb{font-weight:bold}
.fn{font-weight:normal}
.t2{text-indent:2em}
.red,a.red{color:#cc0031}
.darkblue,a.darkblue{color:#039}
.gray,a.gray{color:#878787}
.lh150{line-height:150%}
.lh180{line-height:180%}
.lh200{line-height:200%}
.unl{text-decoration:underline;}
.no_unl{text-decoration:none;}

/*定位*/
.tl{text-align:left}
.tc{text-align:center}
.tr{text-align:right}
.fl{float:left;display:inline}
.fr{float:right;display:inline}
.cb{clear:both}
.cl{clear:left}
.cr{clear:right}
.vm{vertical-align:middle} 
.pr{position:relative} 
.pa{position:absolute}
.abs-right{position:absolute;right:0}
.zoom{zoom:1} 
.hidden{visibility:hidden} 
.none{display:none}

/*長度高度*/
.w10{width:10px}
.w20{width:20px}
.w50{width:50px}
.w90{width:90px}
.w100{width:100px}
.w200{width:200px}
.w250{width:250px}
.w500{width:500px}
.w800{width:800px}
.w{width:100%}
.h50{height:50px}
.h80{height:80px}
.h100{height:100px}
.h200{height:200px}
.h{height:100%}

/*邊距*/
.m10{margin:10px}
.m15{margin:15px}
.m30{margin:30px}
.mt5{margin-top:5px}
.mt10{margin-top:10px}
.mt15{margin-top:15px}
.mt50{margin-top:50px}
.mt100{margin-top:100px}
.mb5{margin-bottom:5px}
.mb10{margin-bottom:10px}
.mb15{margin-bottom:15px}
.mb100{margin-bottom:100px}
.ml5{margin-left:5px}
.ml10{margin-left:10px}
.ml15{margin-left:15px}
.ml20{margin-left:20px}
.ml30{margin-left:30px}
.ml50{margin-left:50px}
.ml100{margin-left:100px}
.mr5{margin-right:5px}
.mr10{margin-right:10px}
.mr15{margin-right:15px}
.mr50{margin-right:50px}
.mr100{margin-right:100px}
.p10{padding:10px;}
.p15{padding:15px;}
.p30{padding:30px;}
.pt5{padding-top:5px}
.pt10{padding-top:10px}
.pt15{padding-top:15px}
.pt20{padding-top:20px}
.pt30{padding-top:30px}
.pt50{padding-top:50px}
.pb5{padding-bottom:5px}
.pb100{padding-bottom:100px}
.pl5{padding-left:5px}
.pl10{padding-left:10px}
.pl50{padding-left:50px}
.pl100{padding-left:100px}
.pr5{padding-right:5px}
.pr10{padding-right:10px}
.pr15{padding-right:15px}
.pr100{padding-right:100px}

/***********通用基本類2************/

/* Copyright 2008 TSXMLOVE. All Rights Reserved. */
* {
padding: 0px;
margin: 0px;
text-align: left;
font-family:Arial, Verdana, Tahoma, "宋體", Helvetica, sans-serif;
line-height: 150%;
}
body {
font-size: 14px;
text-align: center;
color: #000000;

background-image: url(../Images/body_bg.jpg);
background-repeat: repeat-x;
}
table {
border-collapse: collapse;
}
td {
padding: 3px;
}
img {
border: none;
}
input {
padding: 1px;
vertical-align: middle;
line-height: normal;
}
.main-box {
margin-right: auto;
margin-left: auto;
width: 960px;
clear: both;
zoom:1;
overflow:hidden;

}
.text-overflow-hidden {
white-space: nowrap;
word-spacing: normal;
letter-spacing: normal;
overflow: hidden;
}
.box-align-center {
margin-right: auto;
margin-left: auto;
}
/*css定義超連結四個狀態也有順序的。*/

a:link, a:visited {
text-decoration: none;
color: #1F376D;
}
a:hover, a:active {
text-decoration: underline;
color: #BD0A01;
border: none;
}
/*以上語句分別定義了"連結、已訪問過的連結、滑鼠停在上方時、點下滑鼠時"的樣式。
注意,必須按以上順序寫,否則顯示可能和你預想的不一樣。記住它們的順序是“LVHA”。*/
ul {
clear:both;
overflow:hidden;
width: 100%;
}
ul, li {
list-style:none;
}
.valign {
display:table-cell;
*display: inline;
zoom:1;
vertical-align:middle;
}
.text{word-wrap:break-word;overflow:hidden;word-break:break-all;}
/*======================CSS垂直置中=======================*/
.holder {
width:740px;
height:300px;
border:1px solid #777;
text-align:center;
display:table-cell;
vertical-align:middle;
}
/*以下樣式針對IE*/
.edge {
width:0;
height:100%;
display:inline-block;
vertical-align:middle;
}
.container {
vertical-align:middle;
display:inline-block;
}
/*===============================================*/

/*CSS Hack*/
.class {
/*所有瀏覽器*/
*background-color:#00FF00;/*IE*/
_/*IE6*/
}
/*======萬能Float閉合======*/
.clear:after {
    content: ".";
    display: block;
    height: 0;
    clear: both;
    visibility: hidden;
    }

.clear {display: inline-block;} /* for IE/Mac */

/*<!-- main stylesheet ends, CC with new stylesheet below... -->*/

.clear {
    zoom: 1;     /* triggers hasLayout */
    display: block;     /* resets display for IE/Win */
    } /* Only IE can see inside the conditional comment
    and read this CSS rule. Don‘t ever use a normal HTML
    comment inside the CC or it will close prematurely. */
/*======萬能Float閉合2======*/
.overflow-hidden{overflow:hidden;}         /*控制背景溢出*/
.equal-height{margin-bottom:-32800px;padding-bottom:32800px;}      /*控制高度足夠小*/

/*======萬能Float閉合3======*/

.clear 
{
 height:0px;
 clear:both;
 font-size:0px;
 line-height:0px;
 zoom: 1;
}

CSS 公用樣式

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.