如何使CSS图像在div中溢出 [英] How to make css image overflow the div its in

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

问题描述

我在CSS中输入了带有以下代码的图像:

I have a image inputted in the css with the following code:

.imgtemp { 
          float:right; 
          top:0px; 
          left:0px; 
          overflow:visible; 
          width:100%;
        }

我还向页面添加了div标签,以便其显示,但由于设计,图像比div宽。我如何使它溢出divs以使其正确。

I have also added the div tag to the page so its displaying, but the image is wider than the div due to the design. How can I make it overflow the divs its in to get it correct.

谢谢。

推荐答案

正如纳尔逊所说,溢出:隐藏在您的图片对您无济于事。如果您绝对必须使容器的尺寸小于其内部图像的尺寸,则可以使用定位(例如,相对于父级div,相对于顶部和左侧均为0的图像上的绝对值)来忽略其父级的尺寸。您还需要在图像上使用%以外的其他内容,因为%会读出其父级大小,这适得其反。

As Nelson said, overflow: hidden on your image won't help you. If you absolutely must have the container be smaller than the image inside it, you can use positioning (relative on the parent div, absolute on the image with a top and left of 0, for example) to ignore its parent's size. You'll want to use something other than % on the image, too, because the % will read off its parents size, which is counter-productive.

或者,做了您是说要让父div剪切掉多余的图像?

Or, did you mean you want the parent div to cut off the extra image?

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

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