国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

首頁(yè) web前端 css教程 重置默認(rèn)樣式 css reset

重置默認(rèn)樣式 css reset

May 16, 2016 pm 12:04 PM
css reset 樣式

最近看到一個(gè)詞叫css reset。什么叫做css reset呢?我理解為重置css,也就是重置默認(rèn)樣式。

我在HTML下的默認(rèn)樣式中講到,一些標(biāo)簽元素在HTML下有一個(gè)默認(rèn)屬性值,我們?cè)趯?xiě)css頁(yè)面的時(shí)候,為了避免在css中重復(fù)定義它們,我們需要重置默認(rèn)樣式(css reset)。每個(gè)人的用法和寫(xiě)法都不一樣。找到一篇關(guān)于css reset的調(diào)查文章, 可以看看國(guó)外使用css reset的比例調(diào)查。

重置默認(rèn)樣式 css reset


接下來(lái)我也查看了國(guó)內(nèi)的兩個(gè)網(wǎng)站,用Firebug按F12看看他們的css reset怎么寫(xiě)的?
淘寶(www.taobao.com):

html 
{ 
overflow-x:auto; 
overflow-y:scroll; 
} 
body, dl, dt, dd, ul, 
ol, li, pre, form, fieldset, input, p, blockquote, th, td { 
font-weight:400; 
margin:0; 
padding:0; 
} 
h1, h2, h3, h4, h4, h5 { 
margin:0; 
padding:0; 
} 
body { 
background-color:#FFFFFF; 
color:#666666; 
font-family:Helvetica,Arial,sans-serif; 
font-size:12px; 
padding:0 
10px; 
text-align:left; 
} 
select { 
font-size:12px; 
} 
table { 
border-collapse:collapse; 
} 
fieldset, img { 
border:0 
none; 
} 
fieldset { 
margin:0; 
padding:0; 
} 
fieldset p { 
margin:0; 
padding:0 0 0 8px; 
} 
legend { 
display:none; 
} 
address, caption, em, strong, th, i { 
font-style:normal; 
font-weight:400; 
} 
table caption { 
margin-left:-1px; 
} 
hr { 
border-bottom:1px solid #FFFFFF; 
border-top:1px solid #E4E4E4; 
border-width:1px 0; 
clear:both; 
height:2px; 
margin:5px 0; 
overflow:hidden; 
} 
ol, ul { 
list-style-image:none; 
list-style-position:outside; 
list-style-type:none; 
} 
caption, th 
{ 
text-align:left; 
} 
q:before, q:after, blockquote:before, 
blockquote:after { 
content:""; 
}

百度有啊(www.youa.com):(架構(gòu)基本上是模仿YUI來(lái)做的)?

body { 
font-family:arial,helvetica,sans-serif; 
font-size:13px; 
font-size-adjust:none; 
font-stretch:normal; 
font-style:normal; 
font-variant:normal; 
font-weight:normal; 
line-height:1.4; 
text-align:center; 
} 
body, ul, ol, dl, dd, h1, h2, h3, h4, h5, h6, 
p, form, fieldset, legend, input, textarea, select, button, th, td { 
margin:0; 
padding:0; 
} 
h1, h2, h3, h4, h5, h6 { 
font-size:100%; 
font-weight:normal; 
} 
table { 
font-size:inherit; 
} 
input, select { 
font-family:arial,helvetica,clean,sans-serif; 
font-size:100%; 
font-size-adjust:none; 
font-stretch:normal; 
font-style:normal; 
font-variant:normal; 
font-weight:normal; 
line-height:normal; 
} 
button { 
overflow:visible; 
} 
th, em, strong, b, address, cite { 
font-style:normal; 
font-weight:normal; 
} 
li { 
list-style-image:none; 
list-style-position:outside; 
list-style-type:none; 
} 
img, fieldset { 
border:0 none; 
} 
ins { 
text-decoration:none; 
}

在《超越css》一書(shū)中建議我們做網(wǎng)站開(kāi)始重置所有默認(rèn)樣式:

/* Normalizes margin,padding */ 
body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,fieldset,input,p,blockquote,th,td 
{ margin:0;padding:0} 
/* Normalizes font-size for headers */ 
h1,h2,h3,h4,h5,h6 { font-size:100%} 
/* Removes list-style from lists */ 
ol,ul { list-style:none } 
/* Normalizes font-size and font-weight to 
normal */ 
address,caption,cite,code,dfn,em,strong,th,var { font-size:normal; 
font-weight:normal } 
/* Removes list-style from lists */ 
table { 
border-collapse:collapse; border-spacing:0 } 
/* Removes border from fieldset 
and img */ 
fieldset,img { border:0 } 
/* Left-aligns text in caption and 
th */ 
caption,th { text-align:left } 
/* Removes quotation marks from q 
*/ 
q:before,q:after { content:''}

那我們實(shí)際寫(xiě)代碼的時(shí)候該怎么來(lái)css reset呢?
我個(gè)人推薦使用(Eric Meyer和YUI)的 css reset

Eric Meyer's Reset: 
html, body, 
div, span, applet, object, iframe, 
h1, h2, h3, h4, h5, h6, p, blockquote, 
pre, 
a, abbr, acronym, address, big, cite, code, 
del, dfn, em, font, 
img, ins, kbd, q, s, samp, 
small, strike, strong, sub, sup, tt, var, 
b, 
u, i, center, 
dl, dt, dd, ol, ul, li, 
fieldset, form, label, legend, 
table, caption, tbody, tfoot, thead, tr, th, td { 
margin: 0; 
padding: 0; 
border: 0; 
outline: 0; 
font-size: 100%; 
vertical-align: baseline; 
background: transparent; 
} 
body { 
line-height: 1; 
} 
ol, ul { 
list-style: none; 
} 
blockquote, q { 
quotes: none; 
} 
blockquote:before, 
blockquote:after, 
q:before, q:after { 
content: ''; 
content: none; 
} 
/* remember to define focus styles! */ 
:focus { 
outline: 0; 
} 
/* remember to highlight inserts somehow! */ 
ins { 
text-decoration: none; 
} 
del { 
text-decoration: line-through; 
} 
/* tables still need 'cellspacing="0"' in the markup */ 
table { 
border-collapse: collapse; 
border-spacing: 0; 
} 
YUI: 
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; 
}

結(jié)合他們的css reset寫(xiě)法,再根據(jù)自己的實(shí)際情況,一定能寫(xiě)出符合自己網(wǎng)站的完美的css reset。

本站聲明
本文內(nèi)容由網(wǎng)友自發(fā)貢獻(xiàn),版權(quán)歸原作者所有,本站不承擔(dān)相應(yīng)法律責(zé)任。如您發(fā)現(xiàn)有涉嫌抄襲侵權(quán)的內(nèi)容,請(qǐng)聯(lián)系admin@php.cn

熱AI工具

Undress AI Tool

Undress AI Tool

免費(fèi)脫衣服圖片

Undresser.AI Undress

Undresser.AI Undress

人工智能驅(qū)動(dòng)的應(yīng)用程序,用于創(chuàng)建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用于從照片中去除衣服的在線人工智能工具。

Clothoff.io

Clothoff.io

AI脫衣機(jī)

Video Face Swap

Video Face Swap

使用我們完全免費(fèi)的人工智能換臉工具輕松在任何視頻中換臉!

熱工具

記事本++7.3.1

記事本++7.3.1

好用且免費(fèi)的代碼編輯器

SublimeText3漢化版

SublimeText3漢化版

中文版,非常好用

禪工作室 13.0.1

禪工作室 13.0.1

功能強(qiáng)大的PHP集成開(kāi)發(fā)環(huán)境

Dreamweaver CS6

Dreamweaver CS6

視覺(jué)化網(wǎng)頁(yè)開(kāi)發(fā)工具

SublimeText3 Mac版

SublimeText3 Mac版

神級(jí)代碼編輯軟件(SublimeText3)

熱門(mén)話題

Laravel 教程
1601
29
PHP教程
1502
276
如何更改CSS中的文本顏色? 如何更改CSS中的文本顏色? Jul 27, 2025 am 04:25 AM

要改變CSS中文本顏色,需使用color屬性;1.使用color屬性可設(shè)置文本前景色,支持顏色名稱(如red)、十六進(jìn)制碼(如#ff0000)、RGB值(如rgb(255,0,0))、HSL值(如hsl(0,100%,50%))以及帶透明度的RGBA或HSLA(如rgba(255,0,0,0.5));2.可將顏色應(yīng)用于包含文本的任何元素,如h1至h6標(biāo)題、段落p、鏈接a(需注意a:link、a:visited、a:hover、a:active不同狀態(tài)的顏色設(shè)置)、按鈕、div、span等;3.最

如何清除未使用的CSS? 如何清除未使用的CSS? Jul 27, 2025 am 02:47 AM

UseAutomatedToolSlikePurgecsSoruncsStoscanAndRemoveUnusedcss; 2. integratePuratePurgingIntoyourBuildProcessviawebpack,vite,vite,ortailwind ’scontentConfiguration; 3.AuditcsSusageWithChroMedEvtoolScoverAgeTabBeforgeForgingToavoidRemovingNeedEdedStyles; 4.safelistdynamic

什么是堆疊上下文? 什么是堆疊上下文? Jul 27, 2025 am 03:55 AM

astackingcontextisaself-containeerrincssthatconthatconthatconthatconthatconthatconthatconthatconthatconthatconthatconthatconthatconthatconthatconthatconteroverlapplapsplatements,wherenestedContextSrextSrextSratcrets-IndexInteractions; itiscreatedByDybyPropertiesLikeLikeZ-IndexonPositionsedElements,Epacity,opacity

描述不同的CSS單元以及何時(shí)使用它們 描述不同的CSS單元以及何時(shí)使用它們 Jul 27, 2025 am 04:24 AM

在網(wǎng)頁(yè)開(kāi)發(fā)中,CSS單位的選擇取決于設(shè)計(jì)需求和響應(yīng)式表現(xiàn)。1.像素(px)用于固定尺寸如邊框和圖標(biāo),但不利于響應(yīng)式設(shè)計(jì);2.百分比(%)根據(jù)父容器調(diào)整大小,適合流式布局但需注意上下文依賴;3.em基于當(dāng)前字體大小,rem基于根元素字體,適合彈性字體和統(tǒng)一主題控制;4.視口單位(vw/vh/vmin/vmax)依據(jù)屏幕尺寸調(diào)整,適合全屏元素和動(dòng)態(tài)UI;5.auto、inherit、initial等值用于自動(dòng)計(jì)算、繼承或重置樣式,有助于靈活布局與樣式管理。合理使用這些單位能提升頁(yè)面靈活性與響應(yīng)性。

如何使用CSS Backdrop-Filter屬性? 如何使用CSS Backdrop-Filter屬性? Aug 02, 2025 pm 12:11 PM

backdrop-filter用于對(duì)元素背后的內(nèi)容應(yīng)用視覺(jué)效果,1.使用backdrop-filter:blur(10px)等語(yǔ)法實(shí)現(xiàn)毛玻璃效果;2.支持blur、brightness、contrast等多種濾鏡函數(shù)并可疊加;3.常用于玻璃態(tài)卡片設(shè)計(jì),需確保元素與背景重疊;4.現(xiàn)代瀏覽器支持良好,可用@supports提供降級(jí)方案;5.避免過(guò)大模糊值和頻繁重繪以優(yōu)化性能,該屬性僅在元素背后有內(nèi)容時(shí)生效。

如何在CSS中樣式鏈接? 如何在CSS中樣式鏈接? Jul 29, 2025 am 04:25 AM

鏈接的樣式應(yīng)通過(guò)偽類區(qū)分不同狀態(tài),1.使用a:link設(shè)置未訪問(wèn)鏈接樣式,2.a:visited設(shè)置已訪問(wèn)鏈接,3.a:hover設(shè)置懸停效果,4.a:active設(shè)置點(diǎn)擊時(shí)樣式,5.a:focus確保鍵盤(pán)可訪問(wèn)性,始終遵循LVHA順序以避免樣式?jīng)_突,可通過(guò)添加padding、cursor:pointer和保留或自定義焦點(diǎn)輪廓來(lái)提升可用性和可訪問(wèn)性,還可使用border-bottom或動(dòng)畫(huà)下劃線等自定義視覺(jué)效果,最終確保鏈接在所有狀態(tài)下均有良好用戶體驗(yàn)和可訪問(wèn)性。

如何將文本集中在CSS中? 如何將文本集中在CSS中? Jul 27, 2025 am 03:16 AM

使用text-align:center實(shí)現(xiàn)文本水平居中;2.使用Flexbox的align-items:center和justify-content:center實(shí)現(xiàn)垂直和水平居中;3.單行文本可通過(guò)設(shè)置line-height等于容器高度來(lái)垂直居中;4.絕對(duì)定位元素可結(jié)合top:50%、left:50%與transform:translate(-50%,-50%)實(shí)現(xiàn)居中;5.CSSGrid的place-items:center也可同時(shí)實(shí)現(xiàn)雙軸居中,現(xiàn)代布局推薦優(yōu)先使用Flexbox或Grid。

什么是用戶代理樣式表? 什么是用戶代理樣式表? Jul 31, 2025 am 10:35 AM

用戶代理樣式表是瀏覽器自動(dòng)應(yīng)用的默認(rèn)CSS樣式,用于確保未添加自定義樣式的HTML元素仍具基本可讀性。它們影響頁(yè)面初始外觀,但不同瀏覽器存在差異,可能導(dǎo)致不一致顯示。開(kāi)發(fā)者常通過(guò)重置或標(biāo)準(zhǔn)化樣式來(lái)解決這一問(wèn)題。使用開(kāi)發(fā)者工具的“計(jì)算”或“樣式”面板可查看默認(rèn)樣式。常見(jiàn)覆蓋操作包括清除內(nèi)外邊距、修改鏈接下劃線、調(diào)整標(biāo)題大小及統(tǒng)一按鈕樣式。理解用戶代理樣式有助于提升跨瀏覽器一致性并實(shí)現(xiàn)精準(zhǔn)布局控制。

See all articles