亚洲AV无码乱码在线观看不卡|最新大伊香蕉精品视频在线|亚洲不卡av一区二区|国产美女无遮挡免费

登錄論壇 | 注冊(cè)會(huì)員 設(shè)為首頁(yè) | 收藏本站
當(dāng)前位置 : 首頁(yè)>軟件學(xué)院>程序開發(fā)>CSS>正文
 
CSS技巧:節(jié)約網(wǎng)頁(yè)代碼編寫時(shí)間

http://m.yibo1263.com 2009-12-31 10:11:13  來(lái)源:東北IT網(wǎng)  編輯:葉子
 

CSS已經(jīng)成為網(wǎng)頁(yè)前端設(shè)計(jì)一個(gè)非常重要的部分,由于寫CSS時(shí)需要考慮的問(wèn)題非常多,老手們創(chuàng)建新頁(yè)面是通常會(huì)沿用以前的CSS框架。但是新手沒有自己的框架,這篇文章可以給新手們一些啟示。

1.簡(jiǎn)單的純CSS Tooltip
通過(guò)這些代碼,你可以做出簡(jiǎn)單的Tooltip。這是CSS代碼:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
a:hover {
background:#ffffff; /*要兼容IE6的話必須添加背景色*/
text-decoration:none;
}
a.tooltip span {
display:none;
padding:2px 3px;
margin-left:8px;
width:130px;
}
a.tooltip:hover span{
display:inline;
position:absolute;
background:#ffffff;
border:1px solid #cccccc;
color:#6c6c6c;
}


HTML代碼如下:

1
Easy <a class="tooltip" href="#">Tooltip<span>This is a Example by imbolo.com.</span></a>.

效果如圖。

2.重設(shè)基本樣式

為了統(tǒng)一不同瀏覽器對(duì)各種HTML標(biāo)簽的默認(rèn)樣式的渲染,我們必須從新定義各種標(biāo)簽的樣式,這樣能對(duì)以后的開發(fā)帶來(lái)方便。重新定義各種HTML標(biāo)簽只需要在CSS的開頭加入以下代碼。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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: none;
}

/* 元素獲得焦點(diǎn)時(shí)的樣式! */
:focus {
outline: 0;
}

/* 特殊文本的樣式! */
ins {
text-decoration: none;
}
del {
text-decoration: line-through;
}

/* 細(xì)線表格樣式 */
table {
border-collapse: collapse;
border-spacing: 0;
}
3.方便的CSS調(diào)試器

這段代碼可以把頁(yè)面上的各種標(biāo)簽嵌套用不同的線條劃分出來(lái),方便你找出BUG。

1
2
3
4
5
6
7
8
* { outline: 2px dotted red }
* * { outline: 2px dotted green }
* * * { outline: 2px dotted orange }
* * * * { outline: 2px dotted blue }
* * * * * { outline: 1px solid red }
* * * * * * { outline: 1px solid green }
* * * * * * * { outline: 1px solid orange }
* * * * * * * * { outline: 1px solid blue }
4.使一個(gè)未設(shè)定寬度的DIV居中

對(duì)于一個(gè)有固定寬度的DIV容器,你可以輕松地通過(guò)margin:auto屬性令他居中。如果要居中的DIV容器并沒有設(shè)置寬度的話,你可以使用下面的CSS代碼:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
.content {
margin: 0 auto 8px;
display: table;
}

.content div {
display: table-cell;
}

<!--[if IE]>
.content {
display: block;
text-align: center;
}
.content div {
display: inline;
zoom: 1;
}
<![endif]-->
5.為大圖片添加偽AJAX的載入圖標(biāo)

等待圖片下載是瀏覽網(wǎng)頁(yè)是意見煩人的事,但用JavaScript動(dòng)態(tài)載入圖片技術(shù)難度又比較大。你可以用CSS加上一個(gè)載入圖標(biāo),緩解訪客等待加載時(shí)的情緒。

1
img { background: url(loading.gif) no-repeat center center; }

本新聞共2頁(yè),當(dāng)前在第1頁(yè)  1  2  

 
收藏】【打印】【進(jìn)入論壇
  相關(guān)文章:

·CSS3 Media Queries 詳解
·CSS實(shí)例教程:非浮動(dòng)區(qū)域設(shè)置寬度
·css的效率和瀏覽器渲染的速度
·關(guān)于CSS HACK 解決兼容的寫法 
·小議使用“完整”的CSS的缺點(diǎn)
·關(guān)于CSS不透明的詳細(xì)介紹 
·CSS中設(shè)置段落間距的方法
·用css網(wǎng)站布局之十步實(shí)錄
·DIV+CSS布局代碼精簡(jiǎn)對(duì)SEO的影響 
·CSS教程:網(wǎng)頁(yè)中英文字體的設(shè)置 
·css3文本陰影屬性text-shadow說(shuō)明 

 
 
 
 
最新文章

中關(guān)村艷照門女主角詳記錄高清組圖 
大連護(hù)士門大尺度艷照高清組圖
iPhone女孩微博爆紅 最寶貴東西換iPhon
反恐精英之父內(nèi)維爾:改變電腦游戲銷售
團(tuán)購(gòu)網(wǎng)站黎明之前:中國(guó)市場(chǎng)慘烈廝殺不
團(tuán)購(gòu)鼻祖Groupon中國(guó)揭秘:快與慢的商業(yè)
Spil Games發(fā)布新的品牌形象
1800配置一臺(tái)主機(jī) 不要顯示器
聯(lián)想V360筆記本模特寫真
愛國(guó)者第四代移動(dòng)硬盤將面市、低電壓保

 
推薦文章
1
2
3
4
5
6
7
8
9
10
iPhone女孩微博爆紅 最寶貴東西換
大連護(hù)士門大尺度艷照高清組圖
中關(guān)村艷照門女主角詳記錄高清組
蘋果員工中毒門
宮如敏不雅照瘋傳 看張馨予韓一菲
深耕市場(chǎng) 永續(xù)經(jīng)營(yíng)——專訪百腦匯
優(yōu)派專業(yè)電子書 讓您回家旅途多姿
揭曉百萬(wàn)大獎(jiǎng)三星bada魅力綻放中
大明龍權(quán)“江湖英雄會(huì)”全國(guó)PK大
永恒之塔校園達(dá)人挑戰(zhàn)賽完美落幕
八卦圖解 More>>
iPhone女孩微博爆紅 最寶貴東西換 大連護(hù)士門大尺度艷照高清組圖
中關(guān)村艷照門女主角詳記錄高清組 宮如敏不雅照瘋傳 看張馨予韓一菲
双桥区| 辽宁省| 馆陶县| 蕲春县| 长岛县| 武威市| 通道| 渝北区| 潼关县| 诸城市| 白玉县| 天门市| 塘沽区| 远安县| 南漳县| 鹿泉市| 房产| 齐齐哈尔市| 平安县| 峨边| 汉寿县| 彩票| 贵州省| 获嘉县| 龙门县| 远安县| 横山县| 嘉峪关市| 西乌珠穆沁旗| 秦皇岛市| 渝北区| 万载县| 濮阳市| 内黄县| 辽宁省| 乌兰县| 浠水县| 桐梓县| 武陟县| 南安市| 汽车|