精通CSS/四/多个背景图像&border-image

1.多个背景图像
<!doctype html>
<html>
<head>
	<title>My Rounded Corner Box</title>
	<meta charset='utf-8'>
	<link rel="stylesheet" type="text/css">
	<style type="text/css">


	.box{
		width: 30em;
		background: #88ac11 url(images/mtop-left.gif) no-repeat top left;
		color:#fff;
		padding:2em 2em 1em 2em ;
		margin-top: 2em;
	}
	h2{
		margin-top: 0;
		font-size: 1.6em;
	}
	/*在一个div中定义多个图像,通过对该属性值的一一对应从而应用样式*/
	.box{
		background-image: url(images/mtop-left.gif),url(images/mtop-right.gif),url(images/mbottom-left.gif),url(images/mbottom-right.gif);
		background-repeat: no-repeat,no-repeat,no-repeat,no-repeat;
		background-position: top left,top right,bottom left,bottom right;
	}
	</style>
</head>
<body>
	<div class="box">
		<h2>My Rounded Corner Box</h2>
		<p>
			This is my rounded corner box. Isn't it spiffing! I think it's the best rounded corner box in the world. I mean, look at those corners. How round are they? Now take a look at the mark-up. That's right, no extraneous div's. Just pure HTML goodness. Sexy huh? I bet you're wondering how I did that? Well it's easy with CSS 3. You simply use multiple background images.
		</p>
	</div>
</body>
</html>

Result:


2.border-image

<!doctype html>
<html>
<head>
	<title>border-image</title>
	<meta charset='utf-8'>
	<link rel="stylesheet" type="text/css">
	<style type="text/css">
	.box{
		width: 30em;
		background: #89ac11;
		padding: 2em 2em 1em 2em;
		color:#fff;
		margin-top: 2em;
	}
	.box h2{
		margin-top: 0;
		font-size: 1.6em;
	}
	.box p{
		margin-bottom: 0;
		line-height: 1.5em;
	}
	/*【转】border-image详解:
	http://www.zhangxinxu.com/wordpress/2010/01/css3-border-image/
	图像来源(①注意图像名字正确与否②路径,弄明白相对于谁)/划分区域大小(九宫格)/裁剪大小/水平/垂直(repeat/round/stretch)
	repeat:按照原始规则一一置放,最后打破原始规则来适应环境(带有残缺);
	around:开始就按照环境计算出适应的个体大小,从而铺满整个区域。
	*/
	.box{
		-webkit-border-image:url(images/corners.gif) 25% 25% 25% 25%/25px round round;
	}
	</style>
</head>
<body>
	<div class="box">
		<h2>My Rounded Corner Box</h2>
		<p>
			This is my rounded corner box. Isn't it spiffing! I think it's the best rounded corner box in the world. I mean, look at those corners. How round are they? Now take a look at the mark-up. That's right, no extraneous div's. Just pure HTML goodness. Sexy huh? I bet you're wondering how I did that? Well it's easy with CSS 3. You simply use multiple background images.
		</p>
	</div>
</body>
</html>

Result:


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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值