您好,登錄后才能下訂單哦!
這篇文章主要講解了“CSS初始化的方法”,文中的講解內(nèi)容簡單清晰,易于學(xué)習(xí)與理解,下面請(qǐng)大家跟著小編的思路慢慢深入,一起來研究和學(xué)習(xí)“CSS初始化的方法”吧!
為什么要初始化CSS?
CSS初始化是指重設(shè)瀏覽器的樣式。不同的瀏覽器默認(rèn)的樣式可能不盡相同,所以開發(fā)時(shí)的第一件事可能就是如何把它們統(tǒng)一。如果沒對(duì)CSS初始化往往會(huì)出現(xiàn)瀏覽器之間的頁面差異。每次新開發(fā)網(wǎng)站或新網(wǎng)頁時(shí)候通過初始化CSS樣式的屬性,為我們將用到的CSS或html標(biāo)簽更加方便準(zhǔn)確,使得我們開發(fā)網(wǎng)頁內(nèi)容時(shí)更加方便簡潔,同時(shí)減少CSS代碼量,節(jié)約網(wǎng)頁下載時(shí)間。
CSS初始化示例代碼
CSS Code復(fù)制內(nèi)容到剪貼板
/* css reset www.admin10000.com */
body,div,dl,dt,dd,ul,ol,li,h2,h3,h4,h5,h6,h7,pre,code,form,fieldset,legend,input,button,textarea,p,blockquote,th,td { margin:0; padding:0; }
body { background:#fff; color:#555; font-size:14px; font-family: Verdana, Arial, Helvetica, sans-serif; }
td,th,caption { font-size:14px; }
h2, h3, h4, h5, h6, h7 { font-weight:normal; font-size:100%; }
address, caption, cite, code, dfn, em, strong, th, var { font-style:normal; font-weight:normal;}
a { color:#555; text-decoration:none; }
a:hover { text-decoration:underline; }
img { border:none; }
ol,ul,li { list-style:none; }
input, textarea, select, button { font:14px Verdana,Helvetica,Arial,sans-serif; }
table { border-collapse:collapse; }
html {overflow-y: scroll;}
/* css common */
.clearfix:after {content: "."; display: block; height:0; clear:both; visibility: hidden;}
.clearfix { *zoom:1; }
上面是CSS重置代碼,這段代碼是我比較喜歡用的一種方式,雖然還不夠完美但是常用的幾乎已經(jīng)都包括了。
下面順便給出html模板,用于每次新開發(fā)頁面使用。
XML/HTML Code復(fù)制內(nèi)容到剪貼板
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="zh-cn">
<head>
<title>網(wǎng)站標(biāo)題 - Admin10000.com </title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Language" content="zh-CN" />
<meta name="Author" content="網(wǎng)頁作者" />
<meta name="Copyright" content="網(wǎng)站版權(quán)" />
<meta name="keywords" content="網(wǎng)站關(guān)鍵字" />
<meta name="description" content="網(wǎng)站描述" />
<link rel="Shortcut Icon" href="網(wǎng)站.ico圖標(biāo)路徑" />
<link type="text/css" rel="stylesheet" href="CSS文件路徑" />
<script type="text/javascript" src="JS文件路徑"></script>
</head>
<body>
</body>
</html>
感謝各位的閱讀,以上就是“CSS初始化的方法”的內(nèi)容了,經(jīng)過本文的學(xué)習(xí)后,相信大家對(duì)CSS初始化的方法這一問題有了更深刻的體會(huì),具體使用情況還需要大家實(shí)踐驗(yàn)證。這里是億速云,小編將為大家推送更多相關(guān)知識(shí)點(diǎn)的文章,歡迎關(guān)注!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請(qǐng)聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。