CSS insertion form: 1. Write the css code into the style attribute of the element tag; 2. Write the css code between the "" tag pairs; 3. . Write the css code in the css file and import it using the link tag; 4. Use the "@import" rule to import the css code file.
The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.
1. What is CSS
CSS (Cascading style sheets), CSS can be used to build style sheets for web pages, and use style sheets to modify web pages. beautifying effect. The so-called cascading can think of a web page as a layer-by-layer structure, with high levels covering low levels. CSS can style web pages hierarchically. (Text size, background color, width and height, borders, etc.)
CSS is a language created and maintained by the W3C organization. It had version 1.0 in 1996 and version 2.0 in 1998. Version 2.1 was released in 2004. There is no overall release time for CSS3. It is split into many small functions and released at different times. For detailed information, you can check the W3C official website.
2. CSS insertion methods
The css style sheet has four insertion methods: inline style, internal style, link tag to introduce external style, and imported style
(1) Inline style (inline style)
Inline style: You can write css code into the style attribute of the element, and add it after the style attribute. css code. Inline styles are written into inline tags.
You can write multiple styles in a style attribute. Different values of the attributes are separated by semicolons (;). This style is called an inline tag. Inline tags only work on the current element.
(2) Internal style
Internal style: You can write CSS styles into tag (), the type="text/css" part is the default value and can be written or not. Among them, text means that the written style is text, and css means that this is a css style sheet.
To add content to the style tag, you need to first write a css content selector to indicate who the style is set on. You must put a curly bracket { } after the tag to set the style, and write the style sheet Go to the specified style tag and select the specified element through the CSS selector, and then set the styles for these elements at the same time, which can make the styles better reused, further separate the structure and style, and improve the semantic level. (Internal styles can only be used on the current page)
(3) External styles
External styles: Reach A set of styles can be used on different pages at the same time. The css file (the file suffix is .css) is introduced into the current page through the link tag.
Self-closing tag. Introduce external css files into the current page so that the external files can be applied to the current style sheet. The href attribute points to the external file address URL, rel="stylesheet" type="text/css" This part of the content is the default value. Write the styles uniformly in an external file and then introduce them through the link tag. This method uses the browser's cache to speed up access and improve user experience.
The css.css file code content is p{color:blue}, and the final performance is consistent with the effect shown above using internal styles.
(4) Import (@import)
Import: mutual reference between two CSS files, use CSS@import rules to introduce external CSS files .
Using the link tag to introduce external CSS style sheets and using imported CSS files will have slightly different implementation effects.
When using the link tag, the CSS files will be loaded before loading the main page part (loaded in order from top to bottom), so that the loaded page will be rendered with styles from the beginning.
When using the import method, the CSS file will be loaded after the entire page is loaded. For some browsers, in some cases, if the page file size is relatively large, a page without styles will appear first. Then it flashes and the effect of setting the style appears. From a user's perspective, this is a flaw of import.
Selection plan and CSS method for introducing another CSS file:
- If you only introduce one CSS file, it is best to use the link link method. (If you want to dynamically import which CSS file through JavaScript, you must use the link tag to import)
- If you need to reference multiple CSS files, first use link to introduce a "directory" CSS file, this "directory" Use import in CSS files to introduce other CSS files.
How to introduce another CSS file into CSS
Suppose there are three css style sheets: one.css; two.css; three.css
Then use A main style style.css, which contains all three style sheets: (pay attention to the path)
@import "one.css"; @import "two.css"; @import "three.css";
When calling, you only need to call style.css.
Import method to import another css file in a css file mainly uses the @import rule
(Learning video sharing: css video tutorial)
The above is the detailed content of What are the css insertion forms?. For more information, please follow other related articles on the PHP Chinese website!

在css中,可用list-style-type属性来去掉ul的圆点标记,语法为“ul{list-style-type:none}”;list-style-type属性可设置列表项标记的类型,当值为“none”可不定义标记,也可去除已有标记。

区别是:css是层叠样式表单,是将样式信息与网页内容分离的一种标记语言,主要用来设计网页的样式,还可以对网页各元素进行格式化;xml是可扩展标记语言,是一种数据存储语言,用于使用简单的标记描述数据,将文档分成许多部件并对这些部件加以标识。

在css中,可以利用cursor属性实现鼠标隐藏效果,该属性用于定义鼠标指针放在一个元素边界范围内时所用的光标形状,当属性值设置为none时,就可以实现鼠标隐藏效果,语法为“元素{cursor:none}”。

在css中,rtl是“right-to-left”的缩写,是从右往左的意思,指的是内联内容从右往左依次排布,是direction属性的一个属性值;该属性规定了文本的方向和书写方向,语法为“元素{direction:rtl}”。

在css中,可以利用“font-style”属性设置i元素不是斜体样式,该属性用于指定文本的字体样式,当属性值设置为“normal”时,会显示元素的标准字体样式,语法为“i元素{font-style:normal}”。

转换方法:1、给英文元素添加“text-transform: uppercase;”样式,可将所有的英文字母都变成大写;2、给英文元素添加“text-transform:capitalize;”样式,可将英文文本中每个单词的首字母变为大写。

在css3中,可以用“transform-origin”属性设置rotate的旋转中心点,该属性可更改转换元素的位置,第一个参数设置x轴的旋转位置,第二个参数设置y轴旋转位置,语法为“transform-origin:x轴位置 y轴位置”。


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

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 English version
Recommended: Win version, supports code prompts!

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),

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

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

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.