Border -radius在图像上不起作用 - 野生动物园

发布于 2025-02-11 22:26:48 字数 1022 浏览 3 评论 0原文

我已经看到已经存在类似的帖子...在那里发布的解决方案对我没有工作。抱歉再次问。

在我的盖茨比项目中,我希望在图像上使用坚固的边框和边界拉迪乌斯。在Chrome上,它看起来如预期,但是在移动设备和Safari上,图像并没有使圆角并溢出边界。我该如何解决?

.imgContainer {
  border: solid 1px #0784b5;
  border-radius: 10px;
  overflow: hidden;
}

.img {
  position: relative;
  border-radius: 10px;
  top: 0;
  left: 0;
}
<div className={styles.imgContainer}>
  <GatsbyImage className={styles.img} 
  image={data.file.childImageSharp.gatsbyImageData} 
  alt="portrait" 
  />
</div>

”

提前感谢!

I have seen that similar posts already exist... the solutions posted there did not work for me tho. Sorry for asking again.

In my gatsby project I want a solid border and border-radius on an image. On Chrome it looks as expected but on mobile devices and Safari the image just does not get the rounded corners and overflows the border. How can I fix this?

.imgContainer {
  border: solid 1px #0784b5;
  border-radius: 10px;
  overflow: hidden;
}

.img {
  position: relative;
  border-radius: 10px;
  top: 0;
  left: 0;
}
<div className={styles.imgContainer}>
  <GatsbyImage className={styles.img} 
  image={data.file.childImageSharp.gatsbyImageData} 
  alt="portrait" 
  />
</div>

Expected output

How it looks on Safari

Thanks in advance!!

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

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

发布评论

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

评论(1

空城仅有旧梦在 2025-02-18 22:26:48

现在已弃用了盖茨比图像软件包,

您可以使用: https .com/plugins/gatsby-plugin-image/

ex:

import { StaticImage } from 'gatsby-plugin-image';

const IndexPage = () => (
  <StaticImage
    src="../images/test_image.jpg"
    alt=""
    imgStyle={{ borderRadius: '20%' }}
  />
);

The gatsby-image package is now deprecated

You can use: https://www.gatsbyjs.com/plugins/gatsby-plugin-image/

Ex:

import { StaticImage } from 'gatsby-plugin-image';

const IndexPage = () => (
  <StaticImage
    src="../images/test_image.jpg"
    alt=""
    imgStyle={{ borderRadius: '20%' }}
  />
);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文