10

http://s1167.photobucket.com/user/unlivedears/media/image-8.jpg.html?sort=3&o=1

http://s1167.photobucket.com/user/unlivedears/media/image-9.jpg.html?sort=3&o=0

请参阅在第一张图片上,由于图片对于正方形来说太长,女孩的头和腿是如何被剪掉的。我怎样才能使它既切断它们又使它们居中?或者如果它太宽,它会切断两侧?

4

1 回答 1

14

Assuming an HTML structure like this:

<div>
    <img />
</div>

Use this css:

div{
    height: 100px;
    width: 80px;
    overflow: hidden;
}

img{
    min-height: 100%;
    min-width: 100%;
}

Or, you could set the image as a background image and use background-size: cover

于 2013-04-07T18:48:08.500 回答