此篇文章不考虑css使用兼容的前提记录,自行适配兼容性
html// 演示为react写法
// widthStyleCss 为变量声明的值
<div style={{"--widthStyle": widthStyleCss}}></div>
cssdiv {
width: calc(var(--widthStyleCss) + 40px);
}
css// 使用css媒体查询可以设置用户系统偏好自动将您网站的主题设置为自定义样式。
@media (prefers-color-scheme: dark) {
body {
background-color: #333;
color: #fff;
}
}
css@media (orientation: landscape) {
body {
background-color: #333
}
}
css.blur { filter: blur(20px) }
css// 会导致子级固定定位的基准位置
.container{
background-color: rgba(255, 255, 255, 0.05);
backdrop-filter: blur(10px);
}
css.circle { clip-path: polygon(50% 0%, 0% 100%, 100% 100%); }
这个在线工具可以生成各种形状的剪辑:Clippy - CSS clip-path maker
css// 锚点或者导航会轻柔的滑动
html { scroll-behavior: smooth }
cssbody { font-size: calc(100% * env(browser-zoom-level)); }
cssp::first-letter {
font-weight: bold;
color: #333;
}
css.element:empty { display: none }
css// 当单词太长不得不断词换行时,会自动添加“-”连字符。
div{
hyphens: auto;
}
css// 可在对应的文字段落前后添加引号
q{
quotes:"“" "”";
}
css// 阻止用户在页面上选择文本
.no-select { user-select: none }
css// 该css可以使元素忽略鼠标事件,比如点击,hover等等
.no-pointer { pointer-events: none }
css// 宽度和高度保持在指定的比例,非常适合使用在视频和图像元素
.aspect-ratio { aspect-ratio: 16 / 9 }
css// contain, fill, cover
.cover-img { object-fit: cover }
cssinput{
caret-color:#ff0000;
}
css.input-radio{
accent-color:#ff00bf
}
本文作者:seek
本文链接:
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!