重置样式
html, body, ul, li, a, p, div {
padding: 0;
margin: 0;
// 设置盒模型
box-sizing: border-box;
// 移除移动端特有的点击高亮效果
-webkit-tap-highlight-color: transparent;
}
body {
font-family: "PingFang SC", "Microsoft YaHei", "Helvetica", "Helvetica Neue", "Tahoma", "Arial", "sans-serif";
font-size: 14px;
}
a, a:hover {
color: #222;
text-decoration: none;
transition-duration: .3s;
}
ul {
list-style: none;
}
input {
outline: none;
}
// 清除浮动
.clearfix:after, .clearfix:before {
content: '';
display: block;
height: 0;
line-height: 0;
clear: both;
visibility: hidden;
}
多余的文字显示...(默认一行)
@mixin ellipsisTxt($line:1) {
text-overflow: ellipsis;
overflow: hidden;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: $line;
}
遮罩层
@mixin coverMask {
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.6);
position: fixed;
top: 0;
left: 0;
}
关闭按钮,默认是16px
@mixin commonCloseStyle($width:16px) {
position: absolute;
width: $width;
height: $width;
right: calc(#{$width}/2);
top: calc(#{$width}/2);
background: transparent;
cursor: pointer;
&:after,
&:before {
content: "\a0";
position: absolute;
transition: .3s;
background: #bbb;
-webkit-transform: rotate(45deg);
transform: rotate(45deg);
}
&:before {
left: 0;
top: calc(#{$width}/2);
width: $width;
height: 1px;
}
&:after {
top: 0;
left: calc(#{$width}/2);
width: 1px;
height: $width;
}
&:hover:after,
&:hover:before {
transition: .3s;
-webkit-transform: rotate(225deg);
transform: rotate(225deg);
}
}
滚动条
@mixin scrollStyle($height:400px) {
height: $height;
overflow-y: auto;
overflow-x: hidden;
position: relative;
// 滚动条宽
&::-webkit-scrollbar {
width: 4px;
border-radius: 10px;
}
// 滚动条 背景槽
&::-webkit-scrollbar-track {
border-radius: 10px;
background-color: #C1CAD2;
}
// 滚动条 拖动条
&::-webkit-scrollbar-thumb {
border-radius: 10px;
background-color: #889098;
}
}
垂直居中显示
@mixin centerBlock {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}
设置对象 变大变小
.btnKaihu {
width: 405px;
height: 112px;
position: absolute;
left: 50%;
top: 50%;
-webkit-animation: bouncedelay 1.2s infinite;
animation: bouncedelay 1.2s infinite;
}
@keyframes bouncedelay {
0%,
80%,
100% {
transform: scale(0.8);
-webkit-transform: scale(0.8);
}
40% {
transform: scale(1.0);
-webkit-transform: scale(1.0);
}
}
遮罩层 内容垂直水平居中 显示
1. html设置
<div class="dialog_module">
<div class="contArea">
<div class="content">内容显示</div>
<img src="/template/web/skin/default/images/close.png" class="btnClose">
</div>
</div>
2. scss样式设置
.dialog_module {
width: 100%;
height: 100%;
background: #00000060;
position: fixed;
z-index: 10;
.contArea {
width: 300px;
height: 300px;
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
background-color: white;
border-radius: 6px;
.content {
font-size: 30px;
}
.btnClose {
width: 40px;
height: 40px;
cursor: pointer;
position: absolute;
right: -60px;
top: 0;
}
}
}
图片onerror设置
<img src="" one rror="this.src='/template/web/skin/default/images/errorImg.png'">
css样式修改背景图
&:hover {
img {
content: url("/skin/default/images/default.svg");
}
}
标签:总结,常用,50%,transform,height,width,webkit,position,CSS
From: https://www.cnblogs.com/songxia/p/17750981.html