图像上的边框半径..(圆角)

发布于 2024-11-29 22:05:11 字数 196 浏览 0 评论 0原文

尝试为也有边框的图像添加圆角。

想出了以下内容:

http://jsfiddle.net/tgqBG/

但它看起来不太好所有图像下方都有空白,并且边框和图像的角不匹配。我做错了什么吗?

谢谢, 韦斯利

Trying to add rounded corners to images, that also have a border.

Came up with the following:

http://jsfiddle.net/tgqBG/

But it doesn't look good at all with the whitespace below the image, and the fact that the corners of the border and image don't match. Am I doing something wrong?

Thanks,
Wesley

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

耳钉梦 2024-12-06 22:05:11

overflow:hidden; 添加到 .thumb_container,将 vertical-align:bottom; 添加到图像。

您可以删除许多其他值,这是更新的 jsfiddle:

http://jsfiddle.net/tgqBG/ 12/

另一种方法(更多浏览器支持)是通过 background-image 显示图像。在我的评论中,我说这会带来问题,因为元素需要固定尺寸,但是我刚刚意识到,通过将图像放在那里但隐藏它可以很容易地解决这个问题。

http://jsfiddle.net/tgqBG/51/

如果没有float,这将不起作用 因为它将获得 100% 的宽度。这是因为 div 的自动属性会呈现为 block

要解决此问题,请将 div 更改为 span,然后添加 display:inline-block;

http://jsfiddle.net/tgqBG/52/

Add overflow:hidden; to .thumb_container, add vertical-align:bottom; to the image.

You can remove a lot of the other values, here is an updated jsfiddle:

http://jsfiddle.net/tgqBG/12/

Another way of doing this (supported by more browsers) is showing the image through background-image. In my comment I said this would pose a problem because the element needs fixed dimensions, however I just realized this can easily be fixed by also putting the image in there but hiding it.

http://jsfiddle.net/tgqBG/51/

This doesn't work without float because it will get a width of 100%. This is because of div's automatic property to be rendered as a block.

To fix this, change div to span and then add display:inline-block;.

http://jsfiddle.net/tgqBG/52/

虐人心 2024-12-06 22:05:11

您应该考虑到,小于其容器(图像)的元素应该具有较小的角半径,以便与外部元素的角半径对齐(意味着具有相同的曲率)。尝试将图像边框半径设置为 15px。这似乎适用于你的例子。

You should take into account that an element that is smaller than its container (the image) should have a smaller corner radius for it to be aligned with the outer elements corner radius (meaning have the same curvature). Try something like 15px for the image border-radius. That seems to work for your example.

数理化全能战士 2024-12-06 22:05:11

试试这个: http://jsfiddle.net/tgqBG/39/

内部图像较小,并且因此需要有更小的边界半径。边距和填充默认为 0。像瘟疫一样避免浮动。垂直对齐:顶部正确对齐图像。

Try this: http://jsfiddle.net/tgqBG/39/

The inner image is smaller, and thusly needs to have a smaller border-radius. Margins and paddings default to 0. Avoid floats like the plague. Vertical-Align:top alings the image correctly.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文