背景剪切 html,用CSS3 background-clip裁剪背景

用CSS3 background-clip裁剪背景,这个方法应用很多。

* 用于指定background是否包含content之外的border,padding。默认值为border-box,即background从包含border在内的地方开始渲染,IE的默认表现也等同于border-box

背景裁剪(背景从border(即包括border在内)开始绘制(渲染)):

#background-clip-border{

-moz-background-clip:border-box;           /* For Firefox */

-webkit-background-clip:border-box;        /* For Chrome, Safari */

-o-background-clip:border-box;             /* For Opera */

-ms-background-clip:border-box;            /* For IE */

background-clip:border-box;                /* For Future */

}

背景裁剪(背景从padding(即包括padding在内)开始绘制):

#background-clip-padding{

-moz-background-clip:padding-box;           /* For Firefox */

-webkit-background-clip:padding-box;        /* For Chrome, Safari */

-o-background-clip:padding-box;             /* For Opera */

-ms-background-clip:padding-box;            /* For IE */

background-clip:padding-box;                /* For Future */

}

背景裁剪(背景从content(即内容部分)开始绘制):

#background-clip-content{

-moz-background-clip:content-box;           /* For Firefox */

-webkit-background-clip:content-box;        /* For Chrome, Safari */

-o-background-clip:content-box;             /* For Opera */

-ms-background-clip:content-box;            /* For IE */

background-clip:content-box;                /* For Future */

}

背景裁剪(将背景裁剪作为文本的填充色):

* 貌似当前只有webkit内核浏览器支持/* 如果你的浏览器支持text值,你将会看到本段文字的颜色直接使用了背景颜色:红色,且背景将被裁剪掉不再显示 */

#background-clip-text{

background-color:#f00;

-webkit-text-fill-color:transparent;

-webkit-background-clip:text;               /* For Chrome, Safari */

background-clip:text;                       /* For Future */

}

这个大家可以用下,有时候非常实用。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值