current position:Home>CSS introduction method
CSS introduction method
2022-05-15 03:12:17【Sorrow from all ages】
1 CSS Three ways to introduce
according to CSS The position of style writing ( Or the way of introduction ),CSS Style sheets can be divided into three categories :
- Inline style sheets ( Inline )
- Internal style sheets ( The embedded )
- External style sheets ( Outer chain )
2 Inline style sheets
Inline style sheets ( Inline style sheets ) Is inside the element tag style Property CSS style , Suitable for modifying simple styles .
<div style="color: red; font-size: 12px;">
Youth is not always in , Get in love
</div>
style
It's just the attributes of the tag- In the middle of double quotation marks , Write in accordance with CSS standard
- You can control the current label setting style
- Because writing is cumbersome , And does not reflect the idea of separating structure from style , Therefore, it is not recommended to use it in large quantities , Only when adding a simple style to the current element , Consider using
- Use the inline style sheet to set CSS, Also known as
Inline introduction
3 Internal style sheets
Internal style sheets ( Embedded style sheets ) Write when HTML Inside the page , It's all about CSS Code extraction , Put it in a single <style>
In the label .
<style type="text/css"> div {
color: red; font-size: 12px; } </style>
<style>
Labels can theoretically be placed on HTML Anywhere in the document , But it is usually placed in the document<head>
In the label- Current browsers already support Omit
type
attribute - In this way , You can easily control the element style settings in the current whole page
- The code structure is clear , But there is no complete separation of structure and style
- Use the internal style sheet to set CSS, Also known as
Embedded introduction
, This is the way we often practice
4 External style sheets
The actual development is external style sheets , It is suitable for more styles , The core is : The style is written separately CSS In file , After the CSS File import to HTML Page usage .
There are two steps to introducing an external style sheet :
- Create a new suffix named :
.css
The style file of , Put all the CSS The code is put in this file - stay HTML On the page , Use
<link>
Tag to import this file
<link rel="stylesheet" type="text/css" href="css File path ">
attribute | effect |
---|---|
rel | Define the relationship between the current document and the linked document , ad locum It needs to be specified as “stylesheet”, Indicates that the linked document is a stylesheet file |
type | Determine the of the linked document MIME type , The most common of this property is MIME The type is “text/css”, This type describes the style sheet , The current browser Omission is already supported “type” attribute |
href | Defines the... Of the linked external style sheet file URL, Can be a relative path , It could be an absolute path |
** Be careful :** Use external style sheet settings CSS, Also known as Outer chain
or Link in
, This method is commonly used in development .
5 CSS Introduction summary
Style sheets | advantage | shortcoming | usage | Control range |
---|---|---|---|---|
Inline style sheets ( Inline ) | Writing is convenient , Weight high | Structure style mixing | Less | Control a label |
Internal style sheets ( The embedded ) | Part of the structure and style are separated | Not completely separated | More | Control a page |
External style sheets ( Outer chain ) | Completely separate structure from style | Need to introduce | most , Hematemesis recommendation | Control multiple pages |
copyright notice
author[Sorrow from all ages],Please bring the original link to reprint, thank you.
https://en.qdmana.com/2022/135/202205142124187221.html
The sidebar is recommended
- Build an electron project based on Vue from scratch
- In Vue project, solve the problem of verification conflict when eslint and prettier are used at the same time
- Vue3 + vuecli4 solve chunk vendors JS file is too large. Scheme summary
- Scheme summary of eslint check before vue3 + vite configuration project operation and eslint check before git submission
- Fatal authentication failed for 'httpxxxx Git 'solution
- Vue's solution to the compatibility of hevc encoded video in each end browser
- Record the solution to the error in obtaining the picture in springboot in Vue
- [Vue] detailed analysis of the life cycle function of Vue components
- [Vue] deeper understanding of user-defined attribute props
- [Vue] front end error: cannot read properties of undefined (reading 'split')
guess what you like
[Vue] asynchronous problem of component value transfer -- the sub component gets the data slowly
[Vue] Vue data changes, but the page is not updated in real time
[element UI] use of form verification -- detailed explanation
[Vue] use of slots - Review
The influence on the fixed positioning element of the inner layer when the outer element has a fixed height and overflows and rolls
Precautions
Change detection strategy of angular component
Angular service and @ injectable
JS, HTML and CSS are not compatible and do not use common knowledge
Properties to be known in angular @ component
Random recommended
- Angular acquisition and operation DOM
- Html2canvas problem
- Use day in Vue JS (time and date processing library)
- Vue cli configuring preprocessor global variables (take less as an example)
- How to use H5 custom tags in Vue?
- Come on, vue2 customize global loading
- Come on, Vue move the end suspension ball assembly
- React routing foundation and transmission parameters
- Come on, Vue graphic verification code component
- JavaScript judges browser types and kernels at home and abroad (including 360, QQ, Sogou, etc.)
- ArcGIS JavaScript 4. Generates a rectangular buffer at the point of X
- Node under window JS installation, environment configuration, setting Taobao image
- Understanding of prototype and prototype object of JavaScript
- How to customize the startup port of react project!
- Why vue3 0 using proxy to realize data listening 2021-06-21
- Front end artifact - download, configuration and use process of Charles (vase) [Mac version]
- React next configures SVG loader and supports SVG configurability
- React native Android phone cannot be opened after installation. Flash back!
- Fetch and Axios failed to request on Android, with error messages: network request failed and network error
- How to upgrade react Babel 7.1.0
- babel7. 0 compatible with IE browser
- Nginx configuring reactrouter browserhistory browserrouter
- JS, react use html2canvas page screenshot and export
- Big data front-end visualization screen -- the road of front-end development
- [a quick introduction and comparison of multiple languages -- JavaScript, typescript, python, golang, trust, Java, ruby]
- Vue element admin login function, token filling, language conversion, routing setting
- Summation of corresponding position elements of multiple lists in Python
- Discussion on HTML page knowledge
- Using Ajax to realize non refresh paging
- HTTP format
- Zhang San has a meal - did he eat the difference between get and post in HTTP?
- The ultimate actual combat of the most complete tourism project based on spring boot + Vue front-end and back-end separation in history (with source code attached), none of them!!!
- Vue basic grammar
- LeetCode 217. There are duplicate elements
- Pagoda does not configure the solution of SSL site accessing HTTPS and jumping to other websites
- Vue3 isProxy
- About the problem that the container will hang up after starting nginx in the docker container
- Introduction to JavaScript
- The core element of large-scale software design is to control complexity. What is the root cause?
- What are the core elements of large-scale software design?