成人国产在线小视频_日韩寡妇人妻调教在线播放_色成人www永久在线观看_2018国产精品久久_亚洲欧美高清在线30p_亚洲少妇综合一区_黄色在线播放国产_亚洲另类技巧小说校园_国产主播xx日韩_a级毛片在线免费

資訊專(zhuān)欄INFORMATION COLUMN

關(guān)于CSS Reset 那些事(三)之 Normalize-zh.css 出爐

harryhappy / 3576人閱讀

摘要:本章節(jié)會(huì)完成所有源代碼翻譯整理,最終會(huì)整理出中文版本并開(kāi)源至供大家交流使用。現(xiàn)已將源代碼開(kāi)源至項(xiàng)目地址源碼解讀上章節(jié)對(duì)與元素,元素,鏈接,語(yǔ)義化文本,內(nèi)嵌元素,群組元素等源碼內(nèi)容已經(jīng)做了解析,這章節(jié)繼續(xù)完成表單,表格部分。

前言

上一章節(jié)我們對(duì)Normalize.css源碼進(jìn)行解析,但是由于其代碼過(guò)長(zhǎng)導(dǎo)致不宜瀏覽,所以表單Forms,表格Table部分內(nèi)容放在此章節(jié)介紹。本章節(jié)會(huì)完成所有源代碼翻譯整理,最終會(huì)整理出Normalize-zh.css中文版本并開(kāi)源至Github供大家交流使用。

回顧:關(guān)于CSS Reset 那些事(二)之 Normalize.css 源碼解讀

Normalize-zh.css 出爐

Normalize-zh.css是根據(jù)對(duì)Normalize.css的源碼分析后,經(jīng)過(guò)學(xué)習(xí)與整理,將源代碼中的英文注釋文檔翻譯為中文版本,方便國(guó)內(nèi)的開(kāi)發(fā)者學(xué)習(xí)和使用,我深知此版本一定有很多不足,希望能得到大家的理解和支持,同樣也很愿意和大家一起完善。

現(xiàn)已將源代碼開(kāi)源至Github
項(xiàng)目地址:https://github.com/Alsiso/normalize-zh

Normalize 源碼解讀 (2)

上章節(jié)對(duì) html與body元素,HTML5元素,鏈接,語(yǔ)義化文本,內(nèi)嵌元素,群組元素 等源碼內(nèi)容已經(jīng)做了解析,這章節(jié)繼續(xù)完成表單Forms,表格Table部分。

源碼地址:https://github.com/necolas/normalize.css/blob/master/normalize.css
源碼版本:v3.0.3

表單 Forms
/**
 * 1. Correct color not being inherited.
 *    Known issue: affects color of disabled elements.
 * 2. Correct font properties not being inherited.
 * 3. Address margins set differently in Firefox 4+, Safari, and Chrome.
 */

button,
input,
optgroup,
select,
textarea {
  color: inherit; /* 1 */
  font: inherit; /* 2 */
  margin: 0; /* 3 */
}

修正所有瀏覽器中顏色不繼承的問(wèn)題

修正所有瀏覽器中字體不繼承的問(wèn)題

修正 Firefox 3+, Safari5 和 Chrome 中外邊距不同的問(wèn)題

有一些瀏覽器會(huì)把form表單中的一些元素 textarea,text,button,select 中的字體和字體顏色默認(rèn)會(huì)設(shè)置成用戶(hù)的字體或者是瀏覽器的字體,并不會(huì)從父元素繼承,所以這里重置了這些元素的默認(rèn)樣式。

/**
 * Address `overflow` set to `hidden` in IE 8/9/10/11.
 */

button {
  overflow: visible;
}

統(tǒng)一 IE 8/9/10/11 overflow屬性為visible

在 IE 8/9/10/11里的button默認(rèn)的overflowhidden,這里統(tǒng)一為visible

/**
 * Address inconsistent `text-transform` inheritance for `button` and `select`.
 * All other form control elements do not inherit `text-transform` values.
 * Correct `button` style inheritance in Firefox, IE 8/9/10/11, and Opera.
 * Correct `select` style inheritance in Firefox.
 */

button,
select {
  text-transform: none;
}

統(tǒng)一各瀏覽器text-transform不會(huì)繼承的問(wèn)題

/**
 * 1. Avoid the WebKit bug in Android 4.0.* where (2) destroys native `audio`
 *    and `video` controls.
 * 2. Correct inability to style clickable `input` types in iOS.
 * 3. Improve usability and consistency of cursor style between image-type
 *    `input` and others.
 */

button,
html input[type="button"], /* 1 */
input[type="reset"],
input[type="submit"] {
  -webkit-appearance: button; /* 2 */
  cursor: pointer; /* 3 */
}

避免 Android 4.0.* 中的 WebKit bug ,該bug會(huì)破壞原生的audiovideo的控制器

更正 iOS 中無(wú)法設(shè)置可點(diǎn)擊的input的問(wèn)題

統(tǒng)一其他類(lèi)型的input的光標(biāo)樣式

這里將可點(diǎn)擊的按鈕,統(tǒng)一設(shè)置鼠標(biāo)樣式為pointer,提高了可用性

/**
 * Re-set default cursor for disabled elements.
 */

button[disabled],
html input[disabled] {
  cursor: default;
}

重置按鈕禁用時(shí)光標(biāo)樣式

/**
 * Remove inner padding and border in Firefox 4+.
 */

button::-moz-focus-inner,
input::-moz-focus-inner {
  border: 0;
  padding: 0;
}

移除 Firefox 4+ 的內(nèi)邊距

/**
 * Address Firefox 4+ setting `line-height` on `input` using `!important` in
 * the UA stylesheet.
 */

input {
  line-height: normal;
}

統(tǒng)一設(shè)置行高為normal

Firefox瀏覽器會(huì)默認(rèn)設(shè)置input[type="button"]的行高為normal !important,這里統(tǒng)一樣式

/**
 * It"s recommended that you don"t attempt to style these elements.
 * Firefox"s implementation doesn"t respect box-sizing, padding, or width.
 *
 * 1. Address box sizing set to `content-box` in IE 8/9/10.
 * 2. Remove excess padding in IE 8/9/10.
 */

input[type="checkbox"],
input[type="radio"] {
  box-sizing: border-box; /* 1 */
  padding: 0; /* 2 */
}

修正 IE 8/9 box-sizing 被設(shè)置為content-box的問(wèn)題

移除 IE 8/9 中多余的內(nèi)邊距

/**
 * Fix the cursor style for Chrome"s increment/decrement buttons. For certain
 * `font-size` values of the `input`, it causes the cursor style of the
 * decrement button to change from `default` to `text`.
 */

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  height: auto;
}

修正 Chrome 中 input [type="number"] 在特定高度和 font-size 時(shí),下面一個(gè)箭頭光標(biāo)變成cursor: text 效果

/**
 * 1. Address `appearance` set to `searchfield` in Safari and Chrome.
 * 2. Address `box-sizing` set to `border-box` in Safari and Chrome.
 */

input[type="search"] {
  -webkit-appearance: textfield; /* 1 */
  box-sizing: content-box; /* 2 */
}

修正 Safari 5 和 Chrome 中appearance被設(shè)置為searchfield的問(wèn)題

修正 Safari 5 和 Chrome 中box-sizing被設(shè)置為border-box的問(wèn)題

searchfield是CSS3的屬性,它可以讓一個(gè)div元素看上去像任何元素,但是瀏覽器支持性并不好,

/**
 * Remove inner padding and search cancel button in Safari and Chrome on OS X.
 * Safari (but not Chrome) clips the cancel button when the search input has
 * padding (and `textfield` appearance).
 */

input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-decoration {
  -webkit-appearance: none;
}

移除原生默認(rèn)樣式,統(tǒng)一search的輸入框樣式

/**
 * Define consistent border, margin, and padding.
 */

fieldset {
  border: 1px solid #c0c0c0;
  margin: 0 2px;
  padding: 0.35em 0.625em 0.75em;
}

定義一致的邊框、外邊距和內(nèi)邊距

/**
 * 1. Correct `color` not being inherited in IE 8/9/10/11.
 * 2. Remove padding so people aren"t caught out if they zero out fieldsets.
 */

legend {
  border: 0; /* 1 */
  padding: 0; /* 2 */
}

修正 IE 6-9 中顏色不能繼承的問(wèn)題

重置內(nèi)邊距

/**
 * Remove default vertical scrollbar in IE 8/9/10/11.
 */

textarea {
  overflow: auto;
}

移除 IE8-11 中默認(rèn)的垂直滾動(dòng)條

/**
 * Don"t inherit the `font-weight` (applied by a rule above).
 * NOTE: the default cannot safely be changed in Chrome and Safari on OS X.
 */

optgroup {
  font-weight: bold;
}

統(tǒng)一設(shè)置optgroup元素font-weight始終為bold

表格 Tables
/**
 * Remove most spacing between table cells.
 */

table {
  border-collapse: collapse;
  border-spacing: 0;
}

td,
th {
  padding: 0;
}

總結(jié)

經(jīng)過(guò)兩個(gè)章節(jié)對(duì)Normalize.css的源碼進(jìn)行了學(xué)習(xí),清晰的了解了它的工作原理,作為傳統(tǒng)CSS Reset替代者,它當(dāng)之無(wú)愧,為大家提供一套很完整的跨瀏覽器解決方案。

不過(guò),你是否會(huì)有和我一樣的需求,比如開(kāi)發(fā)一個(gè)小站,或者一個(gè)PC端的系統(tǒng)時(shí),也許只需要一些簡(jiǎn)單的基礎(chǔ)模塊,比如我只想要簡(jiǎn)單的樣式重置,統(tǒng)一各瀏覽器的效果就好,并不需要HTML5以及CSS3的一些問(wèn)題修復(fù)。

那么下一章,我們來(lái)介紹,如果制定屬于自己的 CSS基礎(chǔ)代碼庫(kù)?

文章版權(quán)歸作者所有,未經(jīng)允許請(qǐng)勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。

轉(zhuǎn)載請(qǐng)注明本文地址:http://systransis.cn/yun/111078.html

相關(guān)文章

  • 關(guān)于CSS Reset 那些(四) 構(gòu)架CSS基礎(chǔ)樣式庫(kù)

    摘要:現(xiàn)在回到我們這一章節(jié)的標(biāo)題,將它做下補(bǔ)充關(guān)于那些事四之基于構(gòu)架基礎(chǔ)樣式庫(kù)基礎(chǔ)庫(kù)構(gòu)思為什么要做基礎(chǔ)庫(kù)我上一章節(jié)的末尾拋出了幾個(gè)問(wèn)題假設(shè)你要做一個(gè)游戲單頁(yè)面,網(wǎng)頁(yè)上并不存在表單內(nèi)容,那么你就要移除一些冗余的代碼,開(kāi)始自定義樣式來(lái)滿足自己的需求。 前言 先來(lái)回顧一下前幾章節(jié),我們都說(shuō)了哪些內(nèi)容: CSS Reset 歷史 與 Normalize.css 介紹 Normalize.css...

    mj 評(píng)論0 收藏0
  • 關(guān)于CSS Reset 那些(四) 構(gòu)架CSS基礎(chǔ)樣式庫(kù)

    摘要:現(xiàn)在回到我們這一章節(jié)的標(biāo)題,將它做下補(bǔ)充關(guān)于那些事四之基于構(gòu)架基礎(chǔ)樣式庫(kù)基礎(chǔ)庫(kù)構(gòu)思為什么要做基礎(chǔ)庫(kù)我上一章節(jié)的末尾拋出了幾個(gè)問(wèn)題假設(shè)你要做一個(gè)游戲單頁(yè)面,網(wǎng)頁(yè)上并不存在表單內(nèi)容,那么你就要移除一些冗余的代碼,開(kāi)始自定義樣式來(lái)滿足自己的需求。 前言 先來(lái)回顧一下前幾章節(jié),我們都說(shuō)了哪些內(nèi)容: CSS Reset 歷史 與 Normalize.css 介紹 Normalize.css...

    Yu_Huang 評(píng)論0 收藏0
  • 關(guān)于CSS Reset 那些(二) Normalize.css 源碼解讀

    摘要:前言上一章節(jié)介紹了的歷史,最后對(duì)做了簡(jiǎn)單的了解,所以從這節(jié)開(kāi)始對(duì)源碼進(jìn)行注釋翻譯與解讀,盡可能從最根本性的問(wèn)題了解它在幫我們做什么回顧關(guān)于那些事一之歷史演變與源碼解讀前面講到的分模塊解讀,就是先黏貼一段源碼,然后根據(jù)官方提供的注釋進(jìn)行翻譯整 前言 上一章節(jié)介紹了CSS Reset的歷史,最后對(duì)Normalize.css做了簡(jiǎn)單的了解,所以從這節(jié)開(kāi)始對(duì)源碼進(jìn)行注釋翻譯與解讀,盡可能從最...

    qujian 評(píng)論0 收藏0

發(fā)表評(píng)論

0條評(píng)論

最新活動(dòng)
閱讀需要支付1元查看
<