- 解决 img 5px 间距的问题
方案1:设置父元素字体大小为 0
方案2:将 img 元素设置为 display: block
方案3:将 img 元素设置为 vertical-align: bottom
解决方案4:给父元素设置 line-height: 5px - 元素的高度与 window 的高度相同
- 修改 input placeholder 样式
.placehoder-custom::-webkit-input-placeholder {
color: #babbc1;
font-size: 12px;
}
- 使用 :not 选择器
li:not(:last-child) {
border-bottom: 1px solid #ebedf0;
}
- 使用 flex 布局将一个元素智能地固定在底部
.container {
height: 100vh;
display: flex;
flex-direction: column;
justify-content: space-between;
}
- 使用 caret-color 来修改input光标的颜色
caret-color: #ffd476;
- 删除input type=“number” 末尾的箭头
.no-arrow::-webkit-outer-spin-button,
.no-arrow::-webkit-inner-spin-button {
-webkit-appearance: none;
}
- outline:none 删除input输入状态线
- 解决iOS滚动条被卡住的问题:在苹果手机上,经常发生元素在滚动时被卡住的情况
body,html{
-webkit-overflow-scrolling: touch;
}
- 绘制三角形
.box {
padding: 15px;
background-color: #f5f6f9;
border-radius: 6px;
display: flex;
align-items: center;
justify-content: center;
}
.triangle {
display: inline-block;
margin-right: 10px;
border: solid 10px transparent;
}
.triangle.bottom {
border-top-color: #0097a7;
}
.triangle.top {
border-bottom-color: #b2ebf2;
}
.triangle.left {
border-right-color: #00bcd4;
}
.triangle.right {
border-left-color: #009688;
}
- 绘制小箭头
.box {
padding: 15px;
background-color: #ffffff;
border-radius: 6px;
display: flex;
align-items: center;
justify-content: center;
}
.arrow {
display: inline-block;
margin-right: 10px;
width: 0;
height: 0;
border: 16px solid;
border-color: transparent #cddc39 transparent transparent;
position: relative;
}
.arrow::after {
content: "";
position: absolute;
right: -20px;
top: -16px;
border: 16px solid;
border-color: transparent #fff transparent transparent;
}
.arrow.bottom {
transform: rotate(270deg);
}
.arrow.top {
transform: rotate(90deg);
}
.arrow.left {
transform: rotate(180deg);
}
.arrow.right {
transform: rotate(0deg);
}
- 隐藏滚动条
.box-hide-scrollbar::-webkit-scrollbar {
display: none;
}
- 自定义选定的文本样式
.box-custom::selection {
color: #ffffff;
background-color: #ff4c9f;
}
- 不允许选择文本
.box p:last-child {
user-select: none;
}
- 将一个元素在水平和垂直方向上居中
display: flex;
align-items: center;
justify-content: center;
- 单行文本溢出时显示省略号
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
max-width: 375px;
- 多行文本溢出时显示省略号
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
- 使用 “filter:grayscale(1)”,使页面处于灰色模式
body{
filter: grayscale(1);
}