首页 > 代码库 > html元素背景样式大小调整

html元素背景样式大小调整

定义元素背景设置 background-size属性cover自适应填充背景,background-size: 100% 100%; background-size: 左右比例  上下比例;

再介绍几个特殊属性:

 

background-clip :

background-origin :

background-size :背景尺寸。

background-break :

 IE兼容background-size添加下面属性

 filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(
    src=http://www.mamicode.com/‘http://img0.bdstatic.com/img/image/6992fdda3cc7cd98d10273a6b34233fb80e7aec90cc.jpg‘,
    sizingMethod=‘scale‘);
——————————————————————————————————————————————————

<!DOCTYPE html>

<html>
<head>
<meta charset="UTF-8">
<title>让IE兼容background-size的方法</title>
 
<style>
.bgpic {
    background-image: url(‘http://img0.bdstatic.com/img/image/6992fdda3cc7cd98d10273a6b34233fb80e7aec90cc.jpg‘);
    background-size: cover;
    filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(
    src=http://www.mamicode.com/‘http://img0.bdstatic.com/img/image/6992fdda3cc7cd98d10273a6b34233fb80e7aec90cc.jpg‘,
    sizingMethod=‘scale‘);
}
</style>
</head>
<body>
 
    <div  class="bgpic" style="width:200px;height:100px;"></div>
 
</body>
</html>