


```
主要的css为:
```
.wrap_hd1 .left_hd1 img{
width: auto;
height:200px;
}
.wrap_hd1 .right_hd1 img{
width: auto;
height:98px;
}
```
>第三种样式图集3
第三种样式是高度保持固定200px,而宽度会被铺满,如图集3,一个明显的缺点就是过宽时图片会被拉伸。感觉项目中不会采用这种方式的。html同图集2.
主要css:
```
.wrap_hd1 .left_hd2 img{
width: 100%;
height:200px;
}
.wrap_hd1 .right_hd2 img{
width: 100%;
height:98px;
}
```
>第四种样式图集4
第四种样式如图集4,主要区别为高度采用`max-height`这样会使竖向无法对齐,宽度如果采用`width:100%`图片会拉伸,宽度如果采用`width:auto`图片会有空隙。
主要css:
```
.wrap_hd1 .left_hd3 img{
width: 100%;
max-height:200px;
}
.wrap_hd1 .right_hd3 img{
width: 100%;
max-height:98px;
}
```
>第五种样式图集5
第五种样式在demo中有两个,一种是左边为横图图集,一种是左边为竖图图集,区别在于横图截取右侧部分,竖图截取下侧部分。js主要过程就是图片加载完成后获取当前图片的宽高,以及其父容器的宽高,两者相对比来决定当前容器中的图以定宽还是定高。缺点是过宽会有空隙。
主要js:
```
$('.j_hdphoto img').each(function(){
var self = this,
box_width,
box_height,
box_scale,
img_width,
img_height,
img_scale;
var img = new Image();
console.log(self.src);
img.onload=function(){
box_width = $(self).parent().width();
box_height = $(self).parent().height() != 0?$(self).parent().height():1;
box_scale = box_width/box_height;//父容器
img_width = $(self).width();
img_height = $(self).height() != 0?$(self).height():1;
img_scale = img_width/img_height;//图片
if(box_scale