日期:2014-05-16  浏览次数:20724 次

css如何让背景图片自适用表格的大小
如题了,我试着如下代码
.background {
background-image: url(../images/man/NULL-1.jpg);
background-repeat: repeat;
background-position: 100% 100%;
}


没搞定
------解决方案--------------------
background-image: url(../images/man/NULL-1.jpg);   背景设置为图片
background-repeat: repeat; 背景图片是否重复
background-position: 100% 100%; 背景图片定位

你这么写当然不能达到你要的效果
------解决方案--------------------
如果你想要的是从右下角平铺背景的话,你这么写是没问题的。
------解决方案--------------------
<style type="text/css">
<!--
body { margin: 0 auto;}
#pic{ max-width:xxpx; max-height:xxpx; (图片本身的长宽) }
#pic img{ width:100%; height:100%; _height:30%;}
-->注:在IE6中height:100%不兼容,只占30%而已!若img是在链接<a href=”#”></a>下则一定要border:none。
</style>
</head>
<body>
<div id="pic">
<img src="" alt=""/>
</div>
</body>