小程序 CSS绘制卡劵思路

总结了一下CSS绘制卡劵的一些思路技巧

效果图
radial-gradient()径向渐变函数,用于实现卡劵的圆形镂空

CSS语法:background: radial-gradient(shape size at position, start-color, ..., last-color);
先做一个长方形,四角圆形镂空。为了方便理解圆形镂空的定位,我用颜色做了一个分区

/* 圆形镂空 */
.G8 {
   
  width: 250px;
  height: 100px;
  position: relative;
  background: 
    radial-gradient(circle at left top, transparent 10px,  #28A4F2 0) top left / 60px 51% no-repeat,
    radial-gradient(circle at left bottom, transparent 10px,  #01ff80 0) bottom left /60px 51% no-repeat,
    radial-gradient(circle at right top, transparent 10px, #ff0000 0) top right /190px 51% no-repeat,
    radial-gradient(circle at right bottom, transparent 10px, #eeff00 0) bottom right /190px 51% no-repeat;
}

其中radial-gradient(circle at left top, transparent 10px, #28A4F2 0) top left / 60px 51% no-repeat的含义是:
left top左上角, transparent 10px,圆形大小,
top left / 60px 51%左上角定位,60和51对应宽和高
no-repeat背景图像将仅显示一次
在这里插入图片描述在这里插入图片描述
四行代码对应四个颜色的位置
蓝绿分区的left红黄分区的bottom对调
在这里插入图片描述在这里插入图片描述
即可得到卡劵的样式

/* 圆形镂空 */
.G8 
  • 3
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
很好,让我来为您解答。 首先,我们需要使用HTML创建信用的基本结构。以下是一个示例代码: ```html <div class="credit-card"> <div class="credit-card__logo"></div> <div class="credit-card__number">1234 5678 9012 3456</div> <div class="credit-card__name">FULL NAME</div> <div class="credit-card__expiration"> <div class="credit-card__expiration-label">Expiration Date</div> <div class="credit-card__expiration-date">MM/YY</div> </div> </div> ``` 接下来,我们需要使用CSS来设计这个信用。以下是一个示例代码: ```css .credit-card { width: 400px; height: 250px; background-color: #fafafa; box-shadow: 0px 8px 16px rgba(0, 0, 0, 0.1); border-radius: 10px; display: flex; flex-direction: column; justify-content: space-between; padding: 30px; box-sizing: border-box; position: relative; } .credit-card__logo { width: 80px; height: 50px; background-image: url('credit-card-logo.png'); background-size: contain; background-repeat: no-repeat; background-position: center; position: absolute; top: 20px; right: 20px; } .credit-card__number { font-size: 24px; font-weight: bold; letter-spacing: 4px; } .credit-card__name { font-size: 18px; font-weight: bold; text-transform: uppercase; } .credit-card__expiration { display: flex; flex-direction: column; justify-content: space-between; align-items: flex-end; } .credit-card__expiration-label { font-size: 12px; font-weight: bold; color: #a9a9a9; } .credit-card__expiration-date { font-size: 18px; font-weight: bold; letter-spacing: 2px; } ``` 上面的CSS样式将为我们的信用添加样式,包括背景颜色,阴影,边框半径,文本样式和位置。 最后,我们只需要将HTML和CSS结合起来,就可以创建一个漂亮的信用了。如果您有自己的信用图标和样式,只需要将其替换为示例代码中的图标和样式即可。 希望这可以帮助您创建一个漂亮的信用

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值