您可以裁剪img
就像这样:
CSS:
.crop-container {
width: 200px;
height: 300px;
overflow: hidden;
}
.crop-container img {
margin-top: -100px;
margin-left: -200px;
}
调整height
和容器的width
调整裁剪img
的尺寸和调整的负面量margin-top
和margin-left
上的img
元素本身来选择要裁剪的图像的哪一部分。
HTML:
<div class="crop-container">
<img src="some-img"/>
</div>
Working Fiddle
编辑: 对于2柱网的替代解决方案具有固定高度的行:
CSS:
body {
margin: 0;
}
div.img {
float: left;
width: 49%;
margin: 0.5%;
height: 100%;
background-size: cover!important;
background-repeat: no-repeat!important;
}
div.row {
height: 300px;
}
HTML:
<div class='row'>
<div class='img' style='background: url("some-image");'> </div>
<div class='img' style='background: url("some-other-image");'> </div>
</div>
<div class='row'>
<div class='img' style='background: url("foo-image");'> </div>
<div class='img' style='background: url("bar-image");'> </div>
</div>
Working Fiddle
您选择器不好。使用'.protrait-crop img' intead – 2014-10-06 15:23:38