容器内的背景图像与CSS中的边框之间的空间

问题描述 投票:0回答:1

我试图在 css 中将图像设置为容器的背景,但我无法让图像填充容器的整个宽度。边框和图像末端之间有一个小空间。

我用于容器的 CSS 如下。

margin: 0;
  padding: 0;
  width: 100%;
  height: 285px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  box-sizing: border-box;
  border: 1px solid;
  border-image-source: linear-gradient(180deg, #ffffff 0%, rgba(255, 255, 255, 0) 100%);
  border-image-slice: 1;
  background-image: url("/src/images/Store/bg.png");
  background-repeat: no-repeat;
  background-size: 100% 100%;
  background-position: center;
  background-clip: border-box;

父元素具有此 css 属性

width: 229px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  box-sizing: border-box;
css background-image border
1个回答
0
投票

有点很难知道你想要什么,因为你应该发布更多代码并且更清楚。

话虽这么说,可以通过将

background-size: cover
而不是
background-size: 100% 100%;
应用于容器元素来解决您的问题吗?

如果这不起作用,请编辑您的答案并更加具体。

© www.soinside.com 2019 - 2024. All rights reserved.