如何停止在div之外显示图像

tho*_*ter 15 html css

考虑这段代码......

<div id="outer" style="position:absolute;width:100px;height:100px;border:1px solid black">
  <div id="inner">
    <img src="http://rabbitempire.org/wp-content/uploads/Pet-Rabbit-Facts.jpg">
  </div>
</div>
Run Code Online (Sandbox Code Playgroud)

我需要添加哪些样式才能使其只显示图像的左上角?

请注意,我不想使用背景图片,因为问题实际上是关于divs,信不信由你,但兔子不属于我的应用程序.哦,在"现实生活中"我不会使用内联css.

Col*_*ock 13

div#outer { overflow:hidden; }?
Run Code Online (Sandbox Code Playgroud)

这里演示:http://jsfiddle.net/J34aJ/


San*_*Win 7

你可以只申请img { max-width: 100%; height: auto; }图片标签