实现一个简单的骨架屏样式

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>骨架屏</title>
  <style>
    body{
      background-color: #f6f6f6;
      font-family: Arial, Helvetica, sans-serif;
      font-size: 15px;
      display: flex;
      justify-content: space-evenly;
      align-items: center;
      min-height: 100vh;
    }
    .card{
      width: 320px;
      background-color: #fff;
      border-radius: 6px;
      box-shadow: 0px 4px 6px rgb(0, 0, 0,.12);
    }
    .image-title{
     height: 200px;
    }
    .image-title img{
      height: inherit;
      width: 100%;
      object-fit: cover;
      border-radius: 6px 6px 0 0;
    }
    .content{
      padding: 2rem 1.8rem;
    }
    h4{
      margin: 0 0 1rem;
      font-size: 1.5rem;
      line-height: 1.5rem;
    }
    .desc{
      font-size: 1rem;
      line-height: 1.4rem;
    }
    .loading .image-title,
    .loading h4,
    .loading .desc{
      background-color: #ededed;
      background: linear-gradient(
        100deg,
        rgba(255,255,255,0) 40%,
        rgba(255,255,255,.5) 50%,
        rgba(255,255,255,0) 60%
      ) #ededed;
      background-size: 200%;
      background-position-x: 180%;
      animation: 1s loading ease-in-out infinite;
    }
    @keyframes loading {
      to {
        background-position-x:-20%
      }
    }
    .loading h4{
      border-radius: 4px;
      min-height: 1.6rem;
      animation-delay: .05s;
    }
    .loading .desc{
      border-radius: 4px;
      min-height: 4rem;
      animation-delay: .06s;
    }
  </style>
</head>
<body>
   <div class="card">
     <div class="image-title">
       <img src="./a.jpeg" alt="骨架屏的图片">
     </div>
     <div class="content">
       <h4>一个大标题</h4>
       <div class="desc">以上就是基于 DOM 的骨架屏自动生成方案,其核心是 evalDOM 函数。这个方案在很多场景下的表现还是令人满意的。不过,网页布局和样式组合的可能性太多,想要在各种场景下都获得理想的效果,
         还有很长的路要走,但既然已经在路上,就勇敢的向前吧</div>
     </div>
   </div>
   <!-- 骨架屏的样式 loading -->
   <div class="card loading">
    <div class="image-title">
    </div>
    <div class="content">
      <h4></h4>
      <div class="desc"></div>
    </div>
  </div>
</body>
</html>

样式效果:
在这里插入图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

开发路上的AZhe

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值