使用css仅在div中显示图像的一部分 [英] Showing only a part of image in div using css

查看:857
本文介绍了使用css仅在div中显示图像的一部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有什么:


我的宽度为200px X 200px

,其中的图像大小为400px X 400 px。

What I have :
I have a div of width 200px X 200px
and image inside it of size 400px X 400 px.

我想做什么:

我想只在div中显示图像的一部分
是吗可能只使用css。如果没有?然后有什么其他方式

(注意:我不想将图像设置为div的背景)

What I want to do :
I want to show only a part of image inside div Is it possible using only css.If not ? Then what are the other ways
(Note : I don't want to set image to background of the div)

我是什么到目前为止已完成:

小提琴: http://jsfiddle.net/ 5Hbr3 / 1 /

<div id="sample">
    <img src="image.jpg" /> 
</div>

我想显示从100,100到300,300的图像。

和滚动条应该消失。

任何帮助将不胜感激。

I want to show image from 100,100 to 300,300.
and scrollbar should disappear.
Any help will be appreciated.

谢谢

推荐答案

使用职位:父元素上的相对和子图像上的位置:绝对

< a href =http://jsfiddle.net/5Hbr3/3/> http://jsfiddle.net/5Hbr3/3/

To使滚动条消失,使用 overflow:hidden (如在JSFiddle中)

To make the scrollbar disappear, use overflow: hidden (as in the JSFiddle)

这篇关于使用css仅在div中显示图像的一部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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