我的React应用在角落有很小的空间

发布于 2025-02-01 13:26:34 字数 672 浏览 5 评论 0原文

我为背景添加了一个图像,但是角落里有很小的空间(请参阅我附加的图片)。

我为此应用了以下代码。
我的另一个网站并没有显示这样。 如何删除这个微小的空白?

function Home() {

    return(
        <div //className='home-background'
        style={{
            backgroundImage: `url(${background})`,
            backgroundRepeat: 'no-repeat',
            backgroundSize: 'cover',
            height: '100vh',
            width: '100vw',
            // backgroundPosition: 'center',
        }}
        >
            <div>Home</div>
        </div>
    )
}

export default Home;

在此处输入图像描述

I've added an image for my background, but there is tiny space at the corner (Please see the pic I attached).

I applied the below code for this.

My other website doesn't show like this.
How can I remove this tiny white space?

function Home() {

    return(
        <div //className='home-background'
        style={{
            backgroundImage: `url(${background})`,
            backgroundRepeat: 'no-repeat',
            backgroundSize: 'cover',
            height: '100vh',
            width: '100vw',
            // backgroundPosition: 'center',
        }}
        >
            <div>Home</div>
        </div>
    )
}

export default Home;

enter image description here

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

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

发布评论

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

评论(2

江挽川 2025-02-08 13:26:34

尝试一下。

html, body {
  margin: 0px;
  padding: 0px;
}

Try this.

html, body {
  margin: 0px;
  padding: 0px;
}
雨后彩虹 2025-02-08 13:26:34

我建议在CSS文件中设置以造型所有元素。

*{
  margin: 0;
  padding: 0;
  box-sizing: border-box;
 }

I recommend setting in the CSS file for styling all elements.

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