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

    AI Hentai Generator

    AI Hentai Generator

    Generate AI Hentai for free.

    Hot Article

    R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
    3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
    R.E.P.O. Best Graphic Settings
    3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
    R.E.P.O. How to Fix Audio if You Can't Hear Anyone
    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)

    What is the purpose of the <progress> element? What is the purpose of the <progress> element? Mar 21, 2025 pm 12:34 PM

    The article discusses the HTML &lt;progress&gt; element, its purpose, styling, and differences from the &lt;meter&gt; element. The main focus is on using &lt;progress&gt; for task completion and &lt;meter&gt; for stati

    What is the purpose of the <datalist> element? What is the purpose of the <datalist> element? Mar 21, 2025 pm 12:33 PM

    The article discusses the HTML &lt;datalist&gt; element, which enhances forms by providing autocomplete suggestions, improving user experience and reducing errors.Character count: 159

    What is the purpose of the <meter> element? What is the purpose of the <meter> element? Mar 21, 2025 pm 12:35 PM

    The article discusses the HTML &lt;meter&gt; element, used for displaying scalar or fractional values within a range, and its common applications in web development. It differentiates &lt;meter&gt; from &lt;progress&gt; and ex

    What is the viewport meta tag? Why is it important for responsive design? What is the viewport meta tag? Why is it important for responsive design? Mar 20, 2025 pm 05:56 PM

    The article discusses the viewport meta tag, essential for responsive web design on mobile devices. It explains how proper use ensures optimal content scaling and user interaction, while misuse can lead to design and accessibility issues.

    How do I use HTML5 form validation attributes to validate user input? How do I use HTML5 form validation attributes to validate user input? Mar 17, 2025 pm 12:27 PM

    The article discusses using HTML5 form validation attributes like required, pattern, min, max, and length limits to validate user input directly in the browser.

    How do I use the HTML5 <time> element to represent dates and times semantically? How do I use the HTML5 <time> element to represent dates and times semantically? Mar 12, 2025 pm 04:05 PM

    This article explains the HTML5 &lt;time&gt; element for semantic date/time representation. It emphasizes the importance of the datetime attribute for machine readability (ISO 8601 format) alongside human-readable text, boosting accessibilit

    What are the best practices for cross-browser compatibility in HTML5? What are the best practices for cross-browser compatibility in HTML5? Mar 17, 2025 pm 12:20 PM

    Article discusses best practices for ensuring HTML5 cross-browser compatibility, focusing on feature detection, progressive enhancement, and testing methods.

    What is the purpose of the <iframe> tag? What are the security considerations when using it? What is the purpose of the <iframe> tag? What are the security considerations when using it? Mar 20, 2025 pm 06:05 PM

    The article discusses the &lt;iframe&gt; tag's purpose in embedding external content into webpages, its common uses, security risks, and alternatives like object tags and APIs.

    See all articles