CSS -- 非常实用的css技巧
文本选择颜色
::selection {
background-color: #616161;
color: #e0e0e0;
}
首字下沉
article p:first-of-type::first-letter {
color: #616161;
float: left;
font-family: Georgia;
font-size: 4rem;
line-height: 4vw;
padding-right: 8px;
}
平滑滚动
html {
scroll-behavior: smooth!important;
}
输入插入符号颜色
.form__input {
width: 80%;
height: 4vw;
outline: 0;
border: 0;
border-radius: 4vw;
background-color: #e0e0e0;
box-shadow: inset 4px 4px 6px #757575, inset -6px -6px 6px #f5f5f5;
padding: 0 0 0 1vw;
font: 400 1vw "Roboto", sans-serif;
color: #212121;
caret-color: #d32f2f;
}
投影
使用投影为透明图像提供更好的阴影效果
.img-wrapper img {
width: 100%;
height: 100%;
object-fit: cover;
filter: drop-shadow(30px 10px 4px #757575);
}
文本居中显示
main {
width: 100%;
height: 80vh;
display: grid;
place-items: center center;
}
自定义滚动条
.content-wrapper {
width: 800px;
height: 400px;
overflow: auto;
}
.content-wrapper::webkit-scrollbar {
width: 12px;
background-color: #bdbdbd;
border-radius: 1vw 1vw 1vw 1vw;
}
.content-wrapper::webkit-scrollbar-thumb:hover {
background-color: #757575;
}
.content-wrapper::webkit-scrollbar-thumb:active {
background-color: #616161;
}
禁用用户选择
.content-header h2 {
user-select: none;
}
竖排文字
.slidebar h2 {
writing-mode: tb-rl;
transform: rotate(-180deg);
}