新浪初始化css
html,body,ul,li,ol,dl,dd,dt,p,h1,h2,h3,h4,h5,h6,form,fieldset,legend,img { margin: 0; padding: 0 } fieldset,img { border: 0 } img { display: block } address,caption,cite,code,dfn,th,var { font-style: normal; font-weight: normal } ul,ol { list-style: none } input { padding-top: 0; padding-bottom: 0; font-family: "SimSun","宋體" } input::-moz-focus-inner { border: 0; padding: 0 } select,input { vertical-align: middle } select,input,textarea { font-size: 12px; margin: 0 } input[type="text"],input[type="password"],textarea { outline-style: none; -webkit-appearance: none } textarea { resize: none } table { border-collapse: collapse }
京東的初始化html
* { margin: 0; padding: 0 } em,i { font-style: normal } li { list-style: none } img { border: 0; vertical-align: middle } button { cursor: pointer } a { color: #666; text-decoration: none } a:hover { color: #c81623 }
一、其實每一個網站的重置樣式應該都是不一樣的。
二、沒有必要的樣式或者是會再次對這個標籤寫樣式的時候,瀏覽器就會二次渲染,因此也要儘可能的減小重置樣式。
三、咱們應該合理靈活的使用標籤,在網頁中有些樣式是如出一轍的,好比全部或者是大部分的文本p標籤中字體樣式同樣並且行高也同樣,那麼能夠統一設置。包括其餘標籤,在大量使用的過程當中能夠統一設置margin,padding,width,height,display,text-align等,這樣能夠減小css樣式,代碼簡潔,可讀可改性高。web
一、重置css能夠總體的調整整個網站的基本樣式,好比網頁佔據的大部分字體樣式,字體大小,字體顏色,還有最基本的有序無序列表和a連接的樣式。
二、在一批擁有一樣的頭部腳部的樣式中,我會把公共的樣式放在重置樣式表裏。
三、還有針對網站的個別標籤的樣式特殊處理,好比我全部的a連接都應該是藍色的等。
四、在須要大幅度使用的樣式的時候,會另取一個類名主要針對須要此樣式的標籤,好比flyLeft{float:left};,flyRight{float:right};向左向右浮動的樣式,或者是清除浮動的樣式。瀏覽器
body, dl, dd, h1, h2, h3, h4, h5, h6, p, form{ margin: 0; } ol,ul{ margin: 0; padding: 0; } li{ list-style: none } input,button,textarea{ padding: 0; } /*另外:button和input自己有2px的邊框,textarea和select自己有1px的邊框,根據實際狀況調整,或是去掉邊框*/ table{ /*爲表格設置合併邊框模型*/ border-collapse: collapse; /*設置表格邊框之間的空白*/ border-spacing: 0px; } /*去掉a連接的下劃線*/ a{ text-decoration: none; } a:hover{ text-decoration: none; } /*個別瀏覽器對語義化標籤的兼容*/ header, section, footer, aside, nav, main, article, figure { display: block; } h1,h2,h3,h4,h5,h6,em,i,b,cite { /*字體樣式不加粗*/ font-weight: normal; font-style: normal; } a,input,button { /* 清除點擊陰影 */ -webkit-tap-highlight-color: rgba(0, 0, 0, 0); } body * { /* 選中文字設置 */ -weibkit-user-select: none; /* 禁止文字縮放 */ -webkit-text-size-adjust: 100%; }