如何裁切图像 [英] How to make images get cut off

查看:43
本文介绍了如何裁切图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

请参见第一个图像,因为图像对于正方形来说太长了,女孩的头部和腿部被切断了.我怎样才能使它既切开又居中?还是如果它太宽会切断边?

See On the first image how the girls head and legs are cut off because the image is too long for the square. How can I make it so that it cuts them both off and centers it? Or if it it too wide it will cut the sides off?

推荐答案

假定这样的HTML结构:

Assuming an HTML structure like this:

<div>
    <img />
</div>

使用此CSS:

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

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

或者,您可以将图像设置为背景图像,并使用 background-size:cover

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

这篇关于如何裁切图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆