Directory:
2. Various advantages and disadvantages of CSS introduction methods
6. All attributes such as text (starting with text and font) |
行注释 | // 这是行注释,注意'//'后面有空格 /* 这是一段注释 */ |
块注释 | /* * 注释以一行(*后面记得有空格) * 注释以二行(*后面记得有空格) * 注释以三行(*后面记得有空格) */ |
① CSS comment writing specifications: 1. Single-line comments: is written directly after the attribute value, such as:
|
② Benefits of writing CSS comments: 1. Use comments to quickly locate complex problems In the code page, styles can be written efficiently, making the code hierarchy clear and modifications more intuitive. 2. CSS annotations (css annotations) can help us explain the CSS files we write, such as explaining the location, function, style, etc. of a certain piece of CSS code, so that we can maintain it at a glance in the future. It is convenient to understand. At the same time, when the team is developing web pages, reasonable and appropriate annotations will help the team understand where the css style corresponds to the html, so that the web page can be developed smoothly and quickly. |
Line comment | // This is a line comment, please note There is a space after '//' /* This is a comment */ |
Block comment | 🎜> * Comments should be in three lines (remember to have spaces after *) */ |
Extension: HTML structure Annotation method
Use
|
Various advantages and disadvantages of CSS introduction methods
① External introduction : The most widely used, one css file can control multiple pages. From the perspective of the entire site, it reduces the number of codes, improves loading speed, and facilitates Maintenance ③ written inside the tag : less used, with the highest weight, a lot of code, slow loading, not conducive to maintenance :
|
Selector type: ① Tag name selection ② ID name selector ③ Class selector ④ Descendant selector ⑤ Group selector ⑥ Pseudo-class selector ⑦ Attribute selector ⑧ Wildcard ⑨ Descendant selector Selector priority: ① Priority of different CSS introduction methods: tag inline style > Header writing style > External reference style > Browser default style . ② CSS selector priority: id > class > tagname. ③ Multiple selections Priority when servers are mixed: Example.a .b c{} and .a c{}, they both point to c, but the former has a higher priority than the latter. Note: When the priorities of selectors pointing to the same target are the same, the later priority is greater than the previous priority; when in the same tag When multiple class names are defined, the priority between each class selector has nothing to do with the arrangement of class names in the HTML, but is related to the arrangement of each class selector in the CSS file. |
CSS naming convention
1. In the naming of rules, always use lowercase letters plus middle letters. The way of underlining is not allowed to use capital letters or _
3. Pay attention to abbreviations when naming, but do not abbreviate blindly 6. ID is used to identify a certain parent container area of a module or page. The name must be unique and not arbitrary. Create a new id 7. Class naming must be concise and concise 8. In addition to resetting the browser default style, it is prohibited to directly add css style settings to html tags, for example: div { width:200px;height:100px;}9. Each rule should ensure that the selector is unique, and it is prohibited to directly set attributes for global .nav/.header/.body and other classes |
For details, see: Lonely Binghai-CSS Coding Specification
1、 区分大小写 2 、 首写符必须是字母,下划线( _ )或者美元符($) 3、 除首字母外的字符,可以由字母,数字,下划线,美元符号组成 4、 不允许包含空格 |
Extension: JS Naming Specification
3. Except the first letter Characters outside of > background背景 属性: CSS3新增的属性: Background syntax: [For details, please see blog background image merging knowledge] background-color: red | #RGB; background-position: X-axis coordinate Y-axis coordinate | left | right | center | top.. background-size: 100px | 30% | cover | contain; background:color url() positon repeat; Note: If the attribute value of background-size only sets one value, the second value will be set to "auto". cover: Expand the background image to a large enough size so that the background image completely covers the background area. contain : Expand the image to its maximum size so that its width and height fit completely within the content area line-height line-height attribute: Set the distance between lines (line height). Syntax: line-height : normal | Detailed explanation of line-height CSS text property
1. Case sensitive 2. The first letter must be a letter, underscore (_) or dollar sign ($)
* background-color
* background-position
* background-size
* background-repeat
* background-origin
* background-clip
* background-attachment
* background-image
属性 浏览器支持 background-size background-origin
Background, line height attributes background-clip
background background Attributes: * background-color * background-position * background-size * background-repeat * background-origin * background-clip * background-attachment * background-image New attributes in CSS3:
Property browser support background-size td>
background-origin
background-clip
CSS 文本属性
属性 描述 color 设置文本颜色 direction 设置文本方向。 line-height 设置行高。 letter-spacing 设置字符间距。 text-align 对齐元素中的文本。 text-decoration 向文本添加修饰。 text-indent 缩进元素中文本的首行。 text-shadow 设置文本阴影。CSS2 包含该属性,但是 CSS2.1 没有保留该属性。 text-transform 控制元素中的字母。 unicode-bidi 设置文本方向。 white-space 设置元素中空白的处理方式。 word-spacing 设置字间距。
Property description
color
Set text Color
direction
Set the text direction.
属性 描述 font 简写属性。作用是把所有针对字体的属性设置在一个声明中。 font-family 设置字体系列。 font-size 设置字体的尺寸。 font-size-adjust 当首选字体不可用时,对替换字体进行智能缩放。(CSS2.1 已删除该属性。) font-stretch 对字体进行水平拉伸。(CSS2.1 已删除该属性。) font-style 设置字体风格。 font-variant 以小型大写字体或者正常字体显示文本。 font-weight 设置字体的粗细。
line-height Set the line height.
letter-spacing
Set character spacing.
text-align
Align text within an element.
text-decoration
Add decoration to text.
text-indent
Indent the first line of text in the element.
text-shadow
Set text shadow. CSS2 includes this property, but CSS2.1 does not retain it.
text-transform
Controls the letters in the element.
unicode-bidi
Set text direction.
white-space
Sets how whitespace in elements is handled.
word-spacing
Set word spacing. CSS font property
Property description
font
Abbreviation attribute. The function is to set all font-specific properties in one statement.
font-family
Set the font family.
font-size
Set the font size.
font-size-adjust
Smart scaling of replacement fonts when the preferred font is unavailable. (This property has been removed in CSS2.1.)
font-stretch
Stretch the font horizontally. (CSS2.1 has removed this attribute.)
font-style
Set the font style.
font-variant
Display text in small caps or normal font.
font-weight
Set the weight of the font.