简体   繁体   English

不包含图片/ img /溢出的圆角:隐藏;

[英]rounded corners not containing image / img / overflow: hidden;

http://jsfiddle.net/sheriffderek/4JkkF/1/ ///new version of fiddle/// http://jsfiddle.net/sheriffderek/4JkkF/1/ /// fiddle的新版本///

please check out this jsfiddle. 请查看此jsfiddle。

I'm having trouble keeping my images within the borders of their respective divs with rounded corners. 我无法将我的图像保持在各自带有圆角的div的边界内。 This was really simple until I was asked to put border-radius on everything... any help would be much appreciated... 这真的很简单,直到要求我在所有内容上加上边框半径...任何帮助将不胜感激...

在此处输入图片说明

a further explanation of situation... 情况的进一步说明...

in a CSM for each "post" i fill fields... 在每个“职位”的CSM中,我填写字段...

one gets called with php as a title, one as a thumbnail, one as a description, AND - one as the image that goes into the slider. 其中一个以php为标题,一个为缩略图,一个为描述,并且-另一个为进入滑块的图像。 (a list of img's) <img src="" alt="">'s etc... (img的列表) <img src="" alt="">'s等...

the whole layout is liquid - and so i need the image to stay behind a "frame" like div... just like in a background-image in css... and change size without messing up the rounded corners... I can do it with styling the img but i just thought for some reason - that the div within which the img lives would dictate the outer edge... but - so far i am wrong... 整个布局是流动的-因此我需要将图像保留在像div这样的“框架”后面...就像在CSS中的背景图像中一样...并在不弄乱圆角的情况下更改大小...我可以用img的样式来做,但是我只是出于某种原因-img所在的div决定了外部边缘...但是-到目前为止,我错了...

When you specify a border-radius , then the content gets "wrapped" inside the borders -- so the image inside your div gets pushed by the corners, not clipped. 当您指定border-radius ,内容将被“包装”在边界内-因此div内的图像会被拐角推动,而不是被剪切。 You can achieve the desired behavior by using the image as a background to the div instead. 您可以通过将图像用作divbackground来实现所需的行为。

A little working demo: little link . 一个小小的工作演示: 小链接

I hope that helped in any manner! 希望对您有所帮助!

but i don't understand why the img is coming out the div in the first place... 但我不明白为什么img首先出现在div中...

The image itself in the 1st case is bigger than the surrounding div. 在第一种情况下,图像本身大于周围的div。 But the surrounding div has an overflow:hidden plus width & height. 但是周围的div溢出:隐藏,加上宽度和高度。

So the surround div.thumbnail wont scale up .. 因此,环绕div.thumbnail不会放大..

My suggestion would be: 我的建议是:

    <div class="thumbnail" style="height:50%;width:50%;position:static">
    <img src="http://derekthomaswood.com/place/blink3.gif" alt="" style="position:static; display: block;width:100%;height:100%">
</div>
<!-- of course adjusting the classes, not as inline css ;-) 
  resizing works over adjusting the div.thumbnails dimensions
-->

HTH Gekkstah HTH盖克斯塔

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM