1. The BFC specification in HTML
BFC stands for Block Formatting Contexts. Elements with BFC properties can be thought of as separate containers. The elements bu ‘hui inside the container influence the layout of the outside elements, and the BFC has some properties that ordinary elements do not.
Ii. Conditions for triggering BFC specifications:
1. Float elements: float values other than None
2. Absolute positioning elements: Position is (Absolute, fixed)
3. Display inline-block, table-cells, or flex
Overflow is (hidden, auto, scroll)
Iii. BFC features and Applications:
1. Solve margin overlay and problems
2. Solve the floating problem
3. Resolve parent-child element overrides
2. There are three intermediate schemes for CSS
1. The elastic box is centered
.parent {
display: flex;
justify-content: center;
align-items: center;
}
Copy the code
2. Position plus movement
.parent {
position: relative;
}
.child {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
Copy the code
3. When the width and height are determined
.parent {
position: relative;
}
.child {
position: absolute;
top: 0;
left: 0;
button:0;
left:0;
margin:auto;
}
Copy the code
3, about the commonJS specification in JS
1. Core: Each file is a module, with its own independent scope, variables, methods, etc., invisible to other modules.
2. Features: (1): All code runs in the module scope and does not pollute the global scope.
(2): The module can be loaded many times, but it will only run once at the first loading, and then the running result will be cached, and the cache result will be read directly after loading. For the module to run again, the cache must be cleared.
(3): The order in which modules are loaded, according to the order in which they appear in the code. Conclusion :(1) the CommonJS specification states that within each module, the module variable represents the current module. This variable is an object whose exports property (module.exports) is the interface to the outside world. Loading a module loads the module.exports property of that module.
(2) The basic function of the require command is to read and execute a JavaScript file and then return the exports object of that module. If no specified module is found, an error is reported.
Difference between import and require
The most important idea in Node programming is modularity. Both import and require are used by modularity. Follow the specifications
Require is an introduction to the AMD specification
Import is an ES6 syntactic standard that must be converted to es5 syntactic call times for browser compatibility
Require is called at run time, so require can theoretically be used anywhere in the code and import is called at compile time, so it has to be at the top of the file
Require is an assignment process. The result of require is an object, a number, a string, a function, etc., and the result of require is assigned to a variable
Import is a deconstruction process, but none of the engines currently implement import. We use Babel in Node to support ES6, which is simply transcoding ES6 to ES5 and then executing it. The import syntax is transcoding to require