【前端笔记】《CSS揭秘》案例

 
1.半透明边框  
 
border: 10px solid hsla(0,0%,100%,.5);
background: white;
background-clip: padding-box;
 
 
 
核心代码:

body {
	background: url('http://csssecrets.io/images/stone-art.jpg');
}

div {
	border: 10px solid hsla(0,0%,100%,.5);
	background: white;
	background-clip: padding-box;
	
	/* styling */
	max-width: 20em;
	padding: 2em;
	margin: 2em auto 0;
	font: 100%/1.5 sans-serif;
}{
	background: url('http://csssecrets.io/images/stone-art.jpg');
}

div {
	border: 10px solid hsla(0,0%,100%,.5);
	background: white;
	background-clip: padding-box;
	
	/* styling */
	max-width: 20em;
	padding: 2em;
	margin: 2em auto 0;
	font: 100%/1.5 sans-serif;
}
2.多重边框
 
background: yellowgreen;
box-shadow: 0 0 10px #655,0 0 15px deeppink,0 2px 5px 15px rgba(0,0,0,.6)
 
 
3.灵活的背景定位
(1)不受padding影响的背景定位
 background: url("code-pirate.svg") no-repeat bottom right #58a;
 background-position: right 20px bottom 10px;
 background-origin: padding-box;
 
 
(2)在content里定位的背景,即会受padding的影响的定位
 background: url() no-repeat bottom right #58a;
 background-position: right 20px bottom 10px;
 background-origin: content-box;
 
 
(3)不想background-position写方位,单位也可以用calc()
 background-position: calc(100% - 20px) calc(100% - 10px);
 
 
4.边框内圆角
div {
  outline: .6em solid #655;
  box-shadow: 0 0 0 .4em #655;
  
  max-width: 10em;
  border-radius: .8em;
  padding: 1em;
  margin: 1em;
  background: tan;
}
 
5.条纹背景
(1)基本的垂直线性渐变
background: linear-gradient(#fb3,#58a);
(2)设置渐变区域的
background:linear-gradient(#fb3 20%,#58a 80%);
(3)背景分为两块色块
background:linear-gradient(#fb3 50%,#58a 80%);
(4)调整渐变尺寸的
background:linear-gradient(#fb3 50%,#58a 50%);
background-size: 100% 30px;
 
跟这样写是一样的效果:
background:linear-gradient(#fb3 50%,#58a 0);
background-size: 100% 30px;
(5)有三个颜色的条纹
background:linear-gradient(#fb3 33.3%,#58a 0,#58a 66.6%,yellowgreen 0);
background-size: 100% 45px;
 
 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值