css 中可以让文字在垂直和水平方向上重叠的两个属性是什么

垂直方向的属性是 line-height。 水平方向的属性是 letter-spacing
letter-spacing用于消除inline-block元素间的换行符空间间隙

阅读更多

BFC,IFC,GFC,FFC规范的理解

BFC (Block Formatting Context )指块级格式化上下文,即一个创建了新的BFC的盒子是独立布局的,盒子里面的子元素的样式不会影响到外面的元素 。
在同一个BFC中,两个毗邻的块级 盒在垂直方向(和布局方向有关系 )的margin会发生折叠 。BFC 决定元素如何对其内容进行布局,也决定与其他元素的关系和相王作用 。

阅读更多

px和em的区别是什么?

px 和 em 都是长度单位,两者的区别是:
px 的值是固定的,指定为多少就是多少,计算比较容易;
em 的值不是固定的,是相对于容器字体的大小,并且 em 会继承父级元素的字体大小 。
浏览器的默认字体高都是 16px,所以未经调整的浏览器都符合 lem=l6px , 那么 12px= 0.75em, 10px=0.625em.
与 em 对应的另一个长度单位是 rem,是指相对于根元素(通常是 HTML 元素)字 体的大小 。

阅读更多

如何让超出宽度的文字显示为省略号?

1
2
3
4
5
6
.text {
overflow:hidden;
width:xxx;
white-space:nowrap;
text-overflow:ellipsis;
}

阅读更多

三大地图APP的调起(百度,高德,腾讯)

关于百度地图,高德地图,腾讯地图在H5中的调起方式总结

阅读更多

git不同账号同一台电脑的配置

在多次谷歌和百度后,终于在尝试中试出了方案,如下:

阅读更多

git修改分支名

git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push –set-upstream origin new_branch # Push the new branch, set local branch to track the new remote

阅读更多

github被屏蔽后如何提交代码

往github上提交代码一直提示错误信息“fatal: unable to access ‘https://github.com/xxxx.git/': Failed to connect to github.com port 443: Connection refused“,被墙了,需要使用代理。

阅读更多

一道数组面试题

用于合并数组对象,例子如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<script>
// old
let oldlist = [
{id:1,list:[1,2,3]},
{id:2,list:[4,5]},
{id:1,list:[4,5]}
];
// 方法一
let keys = Array.from(new Set(oldlist.map(item => item.id)))
let newlist= keys.map(key=>{
var temp = new Array();
oldlist.filter(item=>item.id==key).reduce((pre,cur)=>{
temp = temp.concat(cur.list)
},0)
return {id:key,list:temp}
})
console.log(JSON.stringify(newlist));
// 方法二
function mapObj(list) {
var obj = {};
for (let item of list) {
console.log(!obj[item.id]);
if (!obj[item.id]) {
console.log(item.id);
obj[item.id] = item.list;
}
else {
obj[item.id] = obj[item.id].concat(item.list);
console.log(obj[item.id]);
}
}
return Object.keys(obj).map(key => {
return {
id: key,
list: obj[key]
}
});
}
</script>
</body>
</html>

阅读更多

爬取酷狗付费歌曲

我们来爬一爬

在终端运行py 文件名

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import requests
import json
import re

def get_song(x):
url = "http://songsearch.kugou.com/song_search_v2?callback=jQuery112407470964083509348_1534929985284&keyword={}&" \
"page=1&pagesize=30&userid=-1&clientver=&platform=WebFilter&tag=em&filter=2&iscorrection=1&privilege_filte" \
"r=0&_=1534929985286".format(x)
res = requests.get(url).text
js = json.loads(res[res.index('(') + 1:-2])
data = js['data']['lists']
for i in range(10):
print(str(i + 1) + ">>>" + str(data[i]['FileName']).replace('<em>', '').replace('</em>', ''))
number = int(input("\n请输入要下载的歌曲序号(输入-1退出程序): "))
if number == -1:
exit()
else:
name = str(data[number - 1]['FileName']).replace('<em>', '').replace('</em>', '')
fhash = re.findall('"FileHash":"(.*?)"', res)[number - 1]
hash_url = "http://www.kugou.com/yy/index.php?r=play/getdata&hash=" + fhash
hash_content = requests.get(hash_url)
play_url = ''.join(re.findall('"play_url":"(.*?)"', hash_content.text))
real_download_url = play_url.replace("\\", "")
with open(name + ".mp3", "wb")as fp:
fp.write(requests.get(real_download_url).content)
print("歌曲已下载完成!")


if __name__ == '__main__':
x = input("请输入歌名:")
get_song(x)

阅读更多