【每日一练】29—CSS实现美食卡 UI 设计效果

cc83bfb9d6ae07c7444ef20a6ed7398b.png

今天我们练习的这个案例是一个产品卡片,这个也是一个很常见且实用的效果,具体效果见下图:

d4678b29c52d7aeaaa3d74edba62d8b1.png

HTML代码:

<!doctype html>
<html>
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>【每日一练】29—CSS实现美食卡 UI 设计效果</title>
</head>
<body>
  <div class="container">
    <div class="card">
      <div class="imgBx">
        <img src="img1.jpg">
      </div>
      <div class="contentBx">
        <h2>唯有美食不能辜负</h2>
        <p>人世间除了美人和美景,还有美食,最不能辜负的就是人间美食,我们花了五千年的时间修炼成为人,来人世间一趟多不容易呀,想吃就吃。</p>
        <div class="price">
          <h3><sup>¥</sup>19<small>.99</small></h3>
          <a href="http://www.webqdkf.com" target="_blank">想吃就吃</a>
        </div>
      </div>
    </div>
    <div class="card">
      <div class="imgBx">
        <img src="img2.jpg">
      </div>
      <div class="contentBx">
        <h2>唯有美食不能辜负</h2>
        <p>人世间除了美人和美景,还有美食,最不能辜负的就是人间美食,我们花了五千年的时间修炼成为人,来人世间一趟多不容易呀,想吃就吃</p>
        <div class="price">
          <h3><sup>¥</sup>29<small>.99</small></h3>
          <a href="http://www.webqdkf.com" target="_blank">想吃就吃</a>
        </div>
      </div>
    </div>
    <div class="card">
      <div class="imgBx">
        <img src="img3.jpg">
      </div>
      <div class="contentBx">
        <h2>唯有美食不能辜负</h2>
        <p>人世间除了美人和美景,还有美食,最不能辜负的就是人间美食,我们花了五千年的时间修炼成为人,来人世间一趟多不容易呀,想吃就吃</p>
        <div class="price">
          <h3><sup>¥</sup>39<small>.99</small></h3>
          <a href="http://www.webqdkf.com" target="_blank">想吃就吃</a>
        </div>
      </div>
    </div>
  </div>
</body>
</html>

CSS代码:

*
{
  margin: 0;
  padding: 0;
  font-family: 'Poppins', sans-serif;
}
body
{
  display: flex;
  justify-content: center;
  align-items: center;
  background: #122746;
  min-height: 100vh;
}
.container
{
  position: relative;
  width: 1100px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  padding: 40px 0;
}
.container .card
{
  position: relative;
  width: 300px;
  margin: 20px;
  background: #fff;
}
.container .card .imgBx
{
  position: relative;
  width: 300px;
  height: 225px;
}
.container .card .imgBx img
{
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.container .card .contentBx
{
  position: relative;
  padding: 20px;
}
.container .card .contentBx h2
{
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #111;
}
.container .card .contentBx p
{
  color: #111;
}
.container .card .contentBx .price
{
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
}
.container .card .contentBx .price h3
{
  font-size: 28px;
  color: #607d8b;
}
.container .card .contentBx .price h3 sup
{
  font-weight: 500;
}
.container .card .contentBx .price a
{
  position: relative;
  display: inline-block;
  background: #ff5064;
  padding: 7px 15px;
  text-decoration: none;
  color: #fff;
  letter-spacing: 1px;
  font-weight: 500;
}
.container .card .contentBx .price a:hover
{
  background: #fb2d45;
}

写在最后

以上就是我们今天的【每日一练】的全部内容,希望今天的小练习对你有用,如果你觉得有帮助的话,请点赞我,关注我,并将它分享给你身边做开发的朋友,也许能够帮助到他。

我是杨小爱,我们明天见。

推荐视频内容

学习更多技能

请点击下方公众号

cebaa046e5fdfbe794ca55b7310b35d8.gif

1e31c819d51d09030c027db8aeede61e.jpeg

484b2b167f20da71ef1afab77af939d7.png

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值