.box
{
width:100px;
height:100px;
box-sizing: border-box;
padding:5px;
}
我想在里面 弄个 <img src="pic.jpg">
这个图片 1000 * 1000 的,怎么让她自动正好填充满上面的 box ?
有这个功能吗?
还是得我手动,或者用php 把这个图片调成 90*90 然后放上?
img{width:100%;height:100%}
100100里面放10001000不会变形,其他的尺寸得变形
img{
max-width:100%
}
img{width:100px;height:100px}
如果图片是是10001000的 那么100100比例是不会变的
1.给图片定高定宽:
img{width:100px;height:100px;}
2.给图片设置百分比:
img{width:100%;height:100%}
3.可以将其设为背景图,代码如下:
.box{
width: 100px;
height: 100px;
background: url(http://imgsrc.baidu.com/forum/pic/item/7c1ed21b0ef41bd55bb1024f51da81cb38db3daf.jpg) no-repeat center center/cover;}
img{
width:100%;
height:100%;
}
继承父容器的宽高
直接给图片设置宽度啊... width:100% 还是多少像素不都是行的么