css 的部分 tips

  1. 消除 transition 闪屏
1
2
3
.css {
	transform: translate3d(0, 0, 0);
}
  1. 全局背景图
1
2
3
4
html {
	background: url("bg.jpg") no-repeat center center fixed;
	background-size: cover;
}
  1. 自定义文本选择
1
2
3
::selection {
	background: red;
}
  1. 使页面字体变细变清晰
1
-webkit-font-smoothing: antialiased;
  1. 长按禁止
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
// 禁止长按图片保存
img {
	-webkit-touch-callout: none;
	pointer-events: none; // 像微信浏览器还是无法禁止,加上这行样式即可
}
// 禁止长按选择文字
div {
	-webkit-user-select: none;
}
// 禁止长按呼出菜单
div {
	-webkit-touch-callout: none;
}
  1. 修改谷歌浏览器记住密码后的自动填充表单背景色
1
2
3
4
5
6
7
input:-webkit-autofill,
textarea:-webkit-autofill,
select:-webkit-autofill {
	background-color: rgb(250, 255, 189); /* #FAFFBD; */
	background-image: none;
	color: rgb(0, 0, 0);
}
  1. 文本两端对齐
1
2
3
4
5
6
7
div {
	width: 100px;
	padding: 0 10px;
	background: pink;
	margin-bottom: 10px;
	text-align-last: justify;
}
  1. 图片显示方式
1
2
3
4
img {
	/* fill | contain | cover | none | scale-down */
	object-fit: cover;
}
  1. 修改滚动条样式
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
div::-webkit-scrollbar {
	/* 这里的宽是指竖向滚动条的宽,高是指横向滚动条的高*/
	width: 16px;
	height: 16px;
	background: pink;
}

div::-webkit-scrollbar-thumb {
	border-radius: 10px;
	background: linear-gradient(red, orange);
}
  1. sass 内深度选择器未生效

尝试以下三种方式

1
2
3
/deep/
>>>
::v-deep
  1. 1px 线
  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
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
.clear-fix {
	&::after {
		content: "";
		display: table;
		clear: both;
	}
}

.border-top-1px,
.border-right-1px,
.border-bottom-1px,
.border-left-1px {
	position: relative;

	&::before,
	&::after {
		content: "";
		display: block;
		position: absolute;
		transform-origin: 0 0;
	}
}

$color-row-line: #ebebeb;
$color-col-line: #ebebeb;

.border-top-1px {
	&::before {
		border-top: 1px solid $color-row-line;
		left: 0;
		top: 0;
		width: 100%;
		transform-origin: 0 top;
	}
}

.border-right-1px {
	&::after {
		border-right: 1px solid $color-col-line;
		top: 0;
		right: 0;
		height: 100%;
		transform-origin: right 0;
	}
}

.border-bottom-1px {
	&::after {
		border-bottom: 1px solid $color-row-line;
		left: 0;
		bottom: 0;
		width: 100%;
		transform-origin: 0 bottom;
	}
}

.border-left-1px {
	&::before {
		border-left: 1px solid $color-col-line;
		top: 0;
		left: 0;
		height: 100%;
		transform-origin: left 0;
	}
}

@media (min-resolution: 2dppx) {
	.border-top-1px {
		&::before {
			width: 200%;
			transform: scale(0.5) translateZ(0);
		}
	}
	.border-right-1px {
		&::after {
			height: 200%;
			transform: scale(0.5) translateZ(0);
		}
	}
	.border-bottom-1px {
		&::after {
			width: 200%;
			transform: scale(0.5) translateZ(0);
		}
	}
	.border-left-1px {
		&::before {
			height: 200%;
			transform: scale(0.5) translateZ(0);
		}
	}
}

@media (min-resolution: 3dppx) {
	.border-top-1px {
		&::before {
			width: 300%;
			transform: scale(0.333) translateZ(0);
		}
	}
	.border-right-1px {
		&::after {
			height: 300%;
			transform: scale(0.333) translateZ(0);
		}
	}
	.border-bottom-1px {
		&::after {
			width: 300%;
			transform: scale(0.333) translateZ(0);
		}
	}
	.border-left-1px {
		&::before {
			height: 300%;
			transform: scale(0.333) translateZ(0);
		}
	}
}