css3 让背景图片拉伸填充

关于图片背景拉升的问题,一直都会遇到,今天刚好又遇到了,所以整理了一下。


<!DOCTYPE html>

<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>css3 让背景图片拉伸填充</title>
<meta name="description" content="">
<meta name="keywords" content="">
<link href="" rel="stylesheet">
</head>
<body>
<!--图片实际大小宽度100px,高度100px-->
<!--1、background-size:200px 200px;扩大背景图片的宽度200px,高度200px-->
<div style="height:200px;width:200px;border:1px solid red;background-image:url(images/33.jpg);background-size:200px 200px;">background-size:200px 200px;</div>
<br/>
<!--2、background-size:100% 50%;扩大背景图片为内容区域的宽度100%,高度50%-->
<div style="height:200px;width:200px;border:1px solid red;background-image:url(images/33.jpg);background-size:100% 50%;">background-size:100% 50%;</div>
<br/>
<!--3、background-size:cover;扩大图片的,使其宽度和高度都能放入内容区域-->
<div style="height:200px;width:200px;border:1px solid red;background-image:url(images/33.jpg);background-size:cover;">background-size:cover;</div>
<br/>
<!--4、background-size:contain;缩放图像的最大值,其宽度和高度都能放入内容区域-->
<div style="height:200px;width:200px;border:1px solid red;background-image:url(images/33.jpg);background-size:contain;">background-size:contain;</div>
<br/>
<!--5、background-size:auto;按照图片的实际大小平铺-->
<div style="height:200px;width:200px;border:1px solid red;background-image:url(images/33.jpg);background-size:auto;">background-size:auto;</div>
<br/>
</body>
</html>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值