侧边栏壁纸
博主头像
MicroMatrix 博主等级

明月别枝惊鹊,清风半夜鸣蝉

  • 累计撰写 116 篇文章
  • 累计创建 36 个标签
  • 累计收到 0 条评论

目 录CONTENT

文章目录

前端开发者必备的 CSS 技巧与最佳实践

David
2024-12-18 / 0 评论 / 0 点赞 / 12 阅读 / 0 字

一行代码实现复杂设计和移除图片背景的方法

mix-blend-mode: multiply;

17 行代码实现骨架屏

*[loading='true'] > div:not([loading='true']) {
  background-image: linear-gradient(90deg, #f0f2f5 25%, #e6e8eb 37%, #f0f2f5 63%) !important;
  background-size: 400% 100% !important;
  animation: skeleton-loading 1.4s infinite ease !important;
  border: none !important;
  min-height: 30px;
}
*[loading='true'] > div:not([loading='true']) > * {
  display: none !important;
}
@keyframes skeleton-loading {
  0% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0 50%;
  }
}

[loading='true']此选择器(attribute 选择器)选择了 全部含有 loading 属性且值为 true 的元素,如

<div loading='true'></div>

div:not([loading='true'])此选择器(非选择器)选择了子元素中所有 loading 为 true 的元素,这主要是为了让骨架屏更有层级感:这样它会回到第一个选择器生效(*[loading='true']),在子元素上写 loading='true' 时会将子元素的子元素精细化的展示出来!

0
css

评论区