A very simple fable, a thousand-year-old tree was struck by lightning and still standing, but was destroyed by the invasion of ants. People who think they are proficient in CSS are often confused by small problems. It is usually a very small value. After layers of amplification and distortion, the entire structure will be out of shape. CSS is a very simple language, easy to learn and use, but it is also the most prone to garbage code. This is due to not studying the language in depth. In my opinion, CSS is composed of the following three blocks: default value, inheritance system and weighted system. The default value is the attribute specified by the browser by default if the user does not set the attribute. The CSS framework basically has a file called reset.css, which resets it to eliminate differences between browsers. The inheritance system is what we will focus on below. The weighting system, that is, the issue of priority, is beyond the scope of this article and will not be discussed further.
In CSS, many properties can be inherited. For example, if the font of a paragraph is set to white, the font of its element does not need to be set or is set to inherit, it will be white. These attributes are called inherited properties. It will get the calculated and converted value of the corresponding attribute from the parent element. If the parent element is in the same situation as it, it will continue to look up, and finally use browse if it is not found. The default value of the device.
The following is a list of inherited properties:
border-collapse
- ##border-spacing
- caption-side
- color
- cursor
- direction
- empty-cells
- font ##font-family
- font-stretch
- font-size
- font-size-adjust
- ##font -style
- font-variant
- font-weight
- letter-spacing
- line-height
- list-style
- opacity
- list-style-image
- list-style-type
- quotes
- text -align
- text-indent
- text-transform
- white-space
- word-spacing
- http://www.php.cn/
Ruby | Rouvre |
---|---|
By | 司徒正美 |
table, tr, td, th { border-collapse: collapse; border: 1px solid #000; } table { text-align: right; } td, th { width: 100px; }Originally th should inherit the right-aligned text setting from the table, but it failed... It is also easy to solve this mentally retarded bug in IE8, that is, the display Set inherit in a formula.
table, tr, td, th { border-collapse: collapse; border: 1px solid #000; } table { text-align: right; } td, th { width: 100px; } th { text-align: inherit; }In addition, there are some CSS properties that cannot be inherited, the most classic ones are the border series. It is called a non-inherited property. If we do not set it, we can only get the browser's default value. The default value is called initial value in Firefox. A related piece of good news is that default values can also be specified in Firefox, so we don't need to reset the style! The following is a list of non-inherited properties: background
- border
-
- clear
- display
- float
- height
- left
- margin
- outline
- overflow
- padding
- position
- right
- top
- visibility
- width
##z- index
- #We set the background color for the parent element. If we do not set the child element, the browser's default value of transparent will be obtained (W3C seems to only have The color will be converted to rgb format, and the extra a is Alpha)
Then let's look at auto, which is an ambiguous value but has a concept of length. Applies to the following properties:
overflow
cursor
height
width
marker-offset
margin
- ##margin-* (left|bottom|top|right|start|end)
- top ##bottom
- left
- right
- table-layout
- z-index
- -moz-column-width
- languages
- In measurable properties of block-level elements (e.g. width, height), if no value is set, its default value is auto, but it can easily be overwritten by the value of the parent element, which means it becomes implicitly inherited. In inline elements, since there is no box model, even Firefox will return it if it is not set, which is very detrimental to accurately calculating the width and height of the element. Auto also has symmetry, which we often use in centered layouts. Among non-metric attributes, such as overflow, specific analysis is required.
For more articles related to CSS inheritance and auto, please pay attention to the PHP Chinese website!

Linking CSS files to HTML can be achieved by using elements in part of HTML. 1) Use tags to link local CSS files. 2) Multiple CSS files can be implemented by adding multiple tags. 3) External CSS files use absolute URL links, such as. 4) Ensure the correct use of file paths and CSS file loading order, and optimize performance can use CSS preprocessor to merge files.

Choosing Flexbox or Grid depends on the layout requirements: 1) Flexbox is suitable for one-dimensional layouts, such as navigation bar; 2) Grid is suitable for two-dimensional layouts, such as magazine layouts. The two can be used in the project to improve the layout effect.

The best way to include CSS files is to use tags to introduce external CSS files in the HTML part. 1. Use tags to introduce external CSS files, such as. 2. For small adjustments, inline CSS can be used, but should be used with caution. 3. Large projects can use CSS preprocessors such as Sass or Less to import other CSS files through @import. 4. For performance, CSS files should be merged and CDN should be used, and compressed using tools such as CSSNano.

Yes,youshouldlearnbothFlexboxandGrid.1)Flexboxisidealforone-dimensional,flexiblelayoutslikenavigationmenus.2)Gridexcelsintwo-dimensional,complexdesignssuchasmagazinelayouts.3)Combiningbothenhanceslayoutflexibilityandresponsiveness,allowingforstructur

What does it look like to refactor your own code? John Rhea picks apart an old CSS animation he wrote and walks through the thought process of optimizing it.

CSSanimationsarenotinherentlyhardbutrequirepracticeandunderstandingofCSSpropertiesandtimingfunctions.1)Startwithsimpleanimationslikescalingabuttononhoverusingkeyframes.2)Useeasingfunctionslikecubic-bezierfornaturaleffects,suchasabounceanimation.3)For

@keyframesispopularduetoitsversatilityandpowerincreatingsmoothCSSanimations.Keytricksinclude:1)Definingsmoothtransitionsbetweenstates,2)Animatingmultiplepropertiessimultaneously,3)Usingvendorprefixesforbrowsercompatibility,4)CombiningwithJavaScriptfo

CSSCountersareusedtomanageautomaticnumberinginwebdesigns.1)Theycanbeusedfortablesofcontents,listitems,andcustomnumbering.2)Advancedusesincludenestednumberingsystems.3)Challengesincludebrowsercompatibilityandperformanceissues.4)Creativeusesinvolvecust


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Dreamweaver CS6
Visual web development tools

WebStorm Mac version
Useful JavaScript development tools

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),
