Table of Contents
Foreword
Normalize Source Code Interpretation (2)
Forms
Tables
Normalize-zh.css is released
Summary
Home Web Front-end HTML Tutorial Things About CSS Reset (3) Normalize-zh.css is released_html/css_WEB-ITnose

Things About CSS Reset (3) Normalize-zh.css is released_html/css_WEB-ITnose

Jun 24, 2016 am 11:40 AM

Foreword

In the previous chapter, we parsed the Normalize.css source code, but because the code is too long, it is not suitable for browsing, so the Forms and Table parts are introduced in this chapter. This chapter will complete the translation and sorting of all source codes, and finally sort out the Chinese version of Normalize-zh.css and open source it to Github for everyone to communicate and use.

Review: Things About CSS Reset (2) Normalize.css Source Code Interpretation

Normalize Source Code Interpretation (2)

The previous chapter discussed html and body elements, and HTML5 elements , links, semantic text, embedded elements, group elements and other source code content have been analyzed. This chapter continues to complete the Forms and Table parts.

Source code address: https://github.com/necolas/normalize.css/blob/master/normalize.css
Source code version: 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 */}
Copy after login
  • Fix the problem that colors are not inherited in all browsers
  • Fix the problem that fonts are not inherited in all browsers
  • Fix the different margins in Firefox 3, Safari5 and Chrome Problem
  • Some browsers will set the font and font color of some elements in the form such as textarea, text, button, and select to the user's font or the browser's font by default, and will not change the font from Parent elements inherit, so the default styles of these elements are reset here.

    /** * Address `overflow` set to `hidden` in IE 8/9/10/11. */button {  overflow: visible;}
    Copy after login
    • Unified IE 8/9/10/11 overflow attribute is visible

    The default overflow of button in IE 8/9/10/11 is hidden, here unified as 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;}
    Copy after login
    • Unify the problem that text-transform will not be inherited by all browsers
    /** * 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 */}
    Copy after login
  • Avoid WebKit in Android 4.0.* bug, this bug will destroy the native audio and video controllers
  • Correct the problem that clickable input cannot be set in iOS
  • Unify the cursor style of other types of input
  • Here, clickable buttons are unified to set the mouse style to pointer, which improves usability

    /** * Re-set default cursor for disabled elements. */button[disabled],html input[disabled] {  cursor: default;}
    Copy after login
    • Reset the cursor style when the button is disabled
    /** * Remove inner padding and border in Firefox 4+. */button::-moz-focus-inner,input::-moz-focus-inner {  border: 0;  padding: 0;}
    Copy after login
    • Remove the padding in Firefox 4
    /** * Address Firefox 4+ setting `line-height` on `input` using `!important` in * the UA stylesheet. */input {  line-height: normal;}
    Copy after login
    • Uniformly set the line height to normal

    Firefox browser will set input[type= by default "button"]'s line height is normal !important, the style is unified here

    /** * 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 */}
    Copy after login
  • Fix the problem of IE 8/9 box-sizing being set to content-box
  • Remove IE 8 /9 extra padding
  • /** * 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;}
    Copy after login
    • Fixed the effect of input [type="number"] in Chrome when at a specific height and font-size, the arrow cursor below becomes 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 */}
    Copy after login
  • Fix the issue where appearance is set to searchfield in Safari 5 and Chrome
  • Fix the issue where box-sizing is set to border-box in Safari 5 and Chrome
  • Searchfield is a CSS3 attribute. It can make a div element look like any element, but browser support is not good.

    /** * 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;}
    Copy after login
    • Remove the native default style and unify it. Search input box style
    /** * Define consistent border, margin, and padding. */fieldset {  border: 1px solid #c0c0c0;  margin: 0 2px;  padding: 0.35em 0.625em 0.75em;}
    Copy after login
    • Define consistent borders, outer margins and inner margins
    /** * 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 */}
    Copy after login
  • Correct colors in IE 6-9 Problems that cannot be inherited
  • Reset padding
  • /** * Remove default vertical scrollbar in IE 8/9/10/11. */textarea {  overflow: auto;}
    Copy after login
    • Remove the default vertical scroll bar in IE8-11
    /** * 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;}
    Copy after login
    • Uniformly set the font-weight of optgroup elements to always be bold

    Tables

    /** * Remove most spacing between table cells. */table {  border-collapse: collapse;  border-spacing: 0;}td,th {  padding: 0;}
    Copy after login

    Normalize-zh.css is released

    Normalize-zh.css Based on the analysis of the source code of Normalize.css, after studying and organizing, the English annotation documents in the source code were translated into a Chinese version to facilitate domestic developers to learn and use. I know that this version must have many shortcomings, and I hope it can I have everyone's understanding and support, and I am also willing to work with everyone to improve it.

    The source code is now open source to Github
    Project address: https://github.com/Alsiso/normalize-zh

    Summary

    After two chapters I studied the source code of Normalize.css and clearly understood its working principle. As a replacement for the traditional CSS Reset, it is well-deserved and provides everyone with a complete cross-browser solution.

    However, do you have the same needs as me? For example, when developing a small website or a PC-side system, you may only need some simple basic modules. For example, I only want a simple style reset. , the effect of unifying various browsers is good, and there is no need to fix some problems of HTML5 and CSS3.

    So in the next chapter, we will introduce, how to develop your own basic CSS code library?

    Statement of this Website
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

    Hot AI Tools

    Undresser.AI Undress

    Undresser.AI Undress

    AI-powered app for creating realistic nude photos

    AI Clothes Remover

    AI Clothes Remover

    Online AI tool for removing clothes from photos.

    Undress AI Tool

    Undress AI Tool

    Undress images for free

    Clothoff.io

    Clothoff.io

    AI clothes remover

    Video Face Swap

    Video Face Swap

    Swap faces in any video effortlessly with our completely free AI face swap tool!

    Hot Article

    Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
    3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
    Nordhold: Fusion System, Explained
    3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
    Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
    3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

    Hot Tools

    Notepad++7.3.1

    Notepad++7.3.1

    Easy-to-use and free code editor

    SublimeText3 Chinese version

    SublimeText3 Chinese version

    Chinese version, very easy to use

    Zend Studio 13.0.1

    Zend Studio 13.0.1

    Powerful PHP integrated development environment

    Dreamweaver CS6

    Dreamweaver CS6

    Visual web development tools

    SublimeText3 Mac version

    SublimeText3 Mac version

    God-level code editing software (SublimeText3)

    Hot Topics

    Java Tutorial
    1666
    14
    PHP Tutorial
    1273
    29
    C# Tutorial
    1253
    24
    HTML: The Structure, CSS: The Style, JavaScript: The Behavior HTML: The Structure, CSS: The Style, JavaScript: The Behavior Apr 18, 2025 am 12:09 AM

    The roles of HTML, CSS and JavaScript in web development are: 1. HTML defines the web page structure, 2. CSS controls the web page style, and 3. JavaScript adds dynamic behavior. Together, they build the framework, aesthetics and interactivity of modern websites.

    The Future of HTML, CSS, and JavaScript: Web Development Trends The Future of HTML, CSS, and JavaScript: Web Development Trends Apr 19, 2025 am 12:02 AM

    The future trends of HTML are semantics and web components, the future trends of CSS are CSS-in-JS and CSSHoudini, and the future trends of JavaScript are WebAssembly and Serverless. 1. HTML semantics improve accessibility and SEO effects, and Web components improve development efficiency, but attention should be paid to browser compatibility. 2. CSS-in-JS enhances style management flexibility but may increase file size. CSSHoudini allows direct operation of CSS rendering. 3.WebAssembly optimizes browser application performance but has a steep learning curve, and Serverless simplifies development but requires optimization of cold start problems.

    The Future of HTML: Evolution and Trends in Web Design The Future of HTML: Evolution and Trends in Web Design Apr 17, 2025 am 12:12 AM

    The future of HTML is full of infinite possibilities. 1) New features and standards will include more semantic tags and the popularity of WebComponents. 2) The web design trend will continue to develop towards responsive and accessible design. 3) Performance optimization will improve the user experience through responsive image loading and lazy loading technologies.

    HTML vs. CSS vs. JavaScript: A Comparative Overview HTML vs. CSS vs. JavaScript: A Comparative Overview Apr 16, 2025 am 12:04 AM

    The roles of HTML, CSS and JavaScript in web development are: HTML is responsible for content structure, CSS is responsible for style, and JavaScript is responsible for dynamic behavior. 1. HTML defines the web page structure and content through tags to ensure semantics. 2. CSS controls the web page style through selectors and attributes to make it beautiful and easy to read. 3. JavaScript controls web page behavior through scripts to achieve dynamic and interactive functions.

    HTML: Building the Structure of Web Pages HTML: Building the Structure of Web Pages Apr 14, 2025 am 12:14 AM

    HTML is the cornerstone of building web page structure. 1. HTML defines the content structure and semantics, and uses, etc. tags. 2. Provide semantic markers, such as, etc., to improve SEO effect. 3. To realize user interaction through tags, pay attention to form verification. 4. Use advanced elements such as, combined with JavaScript to achieve dynamic effects. 5. Common errors include unclosed labels and unquoted attribute values, and verification tools are required. 6. Optimization strategies include reducing HTTP requests, compressing HTML, using semantic tags, etc.

    HTML vs. CSS and JavaScript: Comparing Web Technologies HTML vs. CSS and JavaScript: Comparing Web Technologies Apr 23, 2025 am 12:05 AM

    HTML, CSS and JavaScript are the core technologies for building modern web pages: 1. HTML defines the web page structure, 2. CSS is responsible for the appearance of the web page, 3. JavaScript provides web page dynamics and interactivity, and they work together to create a website with a good user experience.

    HTML: Is It a Programming Language or Something Else? HTML: Is It a Programming Language or Something Else? Apr 15, 2025 am 12:13 AM

    HTMLisnotaprogramminglanguage;itisamarkuplanguage.1)HTMLstructuresandformatswebcontentusingtags.2)ItworkswithCSSforstylingandJavaScriptforinteractivity,enhancingwebdevelopment.

    From Text to Websites: The Power of HTML From Text to Websites: The Power of HTML Apr 13, 2025 am 12:07 AM

    HTML is a language used to build web pages, defining web page structure and content through tags and attributes. 1) HTML organizes document structure through tags, such as,. 2) The browser parses HTML to build the DOM and renders the web page. 3) New features of HTML5, such as, enhance multimedia functions. 4) Common errors include unclosed labels and unquoted attribute values. 5) Optimization suggestions include using semantic tags and reducing file size.

    See all articles