当前位置:网站首页>面试常问:rem布局,flex布局等
面试常问:rem布局,flex布局等
2022-06-11 09:16:00 【开心每一天!】
目录
1、rem布局
html{font-size: 16px} div{font-size: 1rem}
这里的rem就是16px;
给html{ font-size: 26.66667vw;};//
26.66667vw = 100px / 375px *100vw,这是iPhone5下的值,如果是其他更大尺寸的手机,26.66667vw的实际像素数要大于100px.
div{font-size:0.16rem};//以100px作为rem,根据UI的px计算更方便
2、flex布局

3、媒体查询-响应式布局
4、event loop

console.log('Hello, 哈默!)进入callstack调用栈,执行结果,在控制台输出Hello,哈默!调用栈清空。
setTimeout(() => {
console.log('回调函数执行')
}, 3000);
进入调用栈,setTimeout(callback, time)是个webapi,5s后才执行callback。此时,调用栈也清空了。
console.log('Hi, 哈默!)进入callstack调用栈,执行结果,在控制台输出Hi,哈默!调用栈清空。
5s过后,callback被推入callback queue,然后被event loop发现,进入调用栈执行。而后调用栈再次清空。
5、宏任务/微任务


6、async/await
await 后面跟的可以是promise对象,简单字符串等,或者是async 函数,但是都会被包装成promise对象。
7、promise避免回调地狱
需求:多个promise请求,且前面的方法返回值后面的正好需要

this.getTodos()
.then(res=>{
//xxxx
return this.getComments();//返回的是promise,故而可以继续使用 .then
})
.then(res=>{
// xxxx
return this.getAlbums()
})
.then(res=>{
console.log('xxx')
})8、Promise.all
Promise.all(p1, p2, p3)
.then(res=>{
// 全部请求结果返回了
})
9、dataset
dom元素的一个属性,在HTML中,使用data-xxx-yyy-zzz这种格式定义的,可以通过dataset获取:
//html
<div id="user" data-id="1234567890" data-user="johndoe" data-date-of-birth>John Doe</div>
//js
const el = document.querySelector('#user');
//可以获取
console.log(el.dataset.id)
//可以设置
el.dataset.dateOfBirth = '1960-10-03';
//可以删除
delete el.dataset.dateOfBirth10、事件代理
将许多重复的元素,比如li等的对于事件的处理函数,交由父元素来统一处理 。
let ul = document.querySelector('ul')
let curId = undefined
ul.onclick = function (e) {
console.log(e)
let event = e || window.event
let target = event.target || event.srcElement
let className = target.className
switch (className) {
case value1:
xxx
break;
case value2:
xxx
break;
default:
break;
}
//配合刚才的dataset,比如data-id,下面就可以使用id
curId = target.dataset.id
}边栏推荐
- ESP8266_ Connect to Alibaba cloud through mqtt protocol
- Day45 storage engine data type integer floating point character type date type enumeration and set type constraints table to table relationships
- P1169 "chessboard making"
- Why is it difficult to implement informatization in manufacturing industry?
- [intelligent development] scheme design and hardware development of sphygmomanometer
- Type-C Bluetooth speaker single port rechargeable OTG solution
- POJ3250「Bad Hair Day」
- Do you know these advantages of ERP system?
- OpenSSL usage
- Remote office related issues to be considered by enterprises
猜你喜欢

document对象

Pulsar job Plaza | Tencent, Huawei cloud, shrimp skin, Zhong'an insurance, streamnational and other hot jobs

CVPR 2021: learning continuous image representation with local implicit image function

Simulation of map and set

报错Output image is bigger(1228800B) than maximum frame size specified in properties(1048576B)

Package details

Device = depthai Device(““, False) TypeError: _init_(): incompatible constructor arguments.

Revisiting Self-Training for Few-Shot Learning of Language Model,EMNLP2021

Sed explanation of shell script (SED command, sed -e, sed s/ new / old /...)

Type-C Bluetooth speaker single port rechargeable OTG solution
随机推荐
Output image is bigger (1228800b) than maximum frame size specified in properties (1048576b)
A summary of the problem type and method for proving the limit of sequence in postgraduate entrance examination
Bowen dry goods | Apache inlong uses Apache pulsar to create data warehousing
Analysis of Kube scheduler disk scheduling source code
Flask (VII) - static file
Blinn Phong reflection model
企业需要考虑的远程办公相关问题
P1169 "chessboard making"
Four data-driven behaviors of integral system
Type-C docking station adaptive power supply patent protection case
Opencv image basic operation (IV) -- image feature extraction (corner detection)
ES6新增特性--箭头函数
Where is it safer to open an account for soda ash futures? How much does it cost to buy at least one hand?
Sword finger offer II 041 Average value of sliding window
Detailed explanation of the difference between construction method and method
ESP8266_SNTP(Simple Network Time Protocol)
Suffix Array
What problems can ERP system help enterprises deal with?
Where is it safer to open an account for soda ash futures? How much do you need to buy at least?
Augmented reality experiment IV of Shandong University