css3向上标签立体,CSS3 立体感的商品打折标签

CSS

语言:

CSSSCSS

确定

.product {

width: 300px;

font-family: sans-serif;

margin: 2%;

}

.product-image {

background: pink;

margin-bottom: 10px;

position: relative;

min-height: 250px;

}

.onsale-section {

position: absolute;

top: -6px;

right: 15px;

}

.onsale-section:after {

position: absolute;

content: '';

display: block;

width: 0;

height: 0;

border-left: 50px solid transparent;

border-right: 50px solid transparent;

border-top: 6px solid #6ec5d5;

}

.onsale {

position: relative;

display: inline-block;

text-align: center;

color: #fff;

background: #6ec5d5;

font-size: 14px;

line-height: 1;

padding: 12px 8px 6px;

border-top-right-radius: 8px;

width: 84px;

text-transform: uppercase;

}

.onsale:before,

.onsale:after {

position: absolute;

content: '';

display: block;

}

.onsale:before {

background: #6ec5d5;

height: 7px;

width: 6px;

left: -6px;

top: 0;

}

.onsale:after {

background: #96a0a2;

height: 7px;

width: 8px;

border-radius: 8px 8px 0 0;

left: -8px;

top: 0;

}

.product img {

display: block;

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
CSS3可以实现很多炫酷的效果,其中包括立体感按钮。下面是一个简单的实现方法: HTML代码: ``` <button class="btn">立体按钮</button> ``` CSS代码: ``` .btn { display: inline-block; position: relative; padding: 10px 20px; background-color: #007bff; border: none; color: #fff; font-size: 16px; text-align: center; text-decoration: none; cursor: pointer; box-shadow: 0 5px 0 #0056b3; transition: all 0.3s ease-in-out; } .btn::before { content: ''; position: absolute; top: -5px; left: -5px; width: calc(100% + 10px); height: calc(100% + 10px); border: 5px solid #007bff; border-radius: 10px; opacity: 0; transition: all 0.3s ease-in-out; } .btn:hover { background-color: #0056b3; box-shadow: 0 2px 0 #0056b3; transform: translateY(3px); } .btn:hover::before { opacity: 1; transform: translateX(-3px) translateY(-3px); } ``` 解释一下代码: 首先,我们创建一个按钮元素,添加一个class为.btn。 接着,我们设置按钮的基本样式,包括颜色、边框、字体等。 然后,我们设置按钮的阴影效果,通过box-shadow属性实现。 接下来,我们使用伪元素::before来添加按钮的立体效果。我们设置一个5像素的边框,通过border-radius属性实现圆角效果,opacity属性设置透明度为0,这样不会显示出来。 最后,我们设置按钮的悬停效果。当鼠标悬停在按钮上时,我们改变按钮的背景颜色和阴影,并将按钮向下移动3像素。同时,我们将伪元素::before的opacity属性设置为1,这样它就会显示出来了。我们还将它向左上方移动3像素,从而实现按钮的立体效果。 这就是一个基本的CSS3立体感按钮的实现方法。你可以根据自己的需要进行修改和扩展,添加更多的效果和交互。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值