我如何正确地定位我的SVG元素,以便它即使在尺寸上

发布于 2025-01-28 17:57:49 字数 627 浏览 1 评论 0原文

因此,我的问题形象。我有两个SVG文件,无论我如何调整窗口大小,我都希望它们粘在底部,如果我将其调整到移动配置大小,我希望它们堆放在每个人的顶部

我想要的图像

这是我的CSS,但是在我调整大小之后,它们甚至不在底部。我有两种不同颜色的背景分开

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

.column1 {
  height: 100vh;
  background-color: #679289;
}
.column2 {
  height: 100vh;
  background-color: #f4c095;
}

.svg1 {
  overflow: visible;
  transform: translate(0px, 68px);
}

.svg1 {
  
  overflow: visible;
  transform: translate(0px, 166px);
}

,也指出SVG的尺寸不是相同的

So heres the image of my problem. I have two SVG files, and i want them to sticky to the bottom no matter how i resize my window, and if I resize it to a mobile configuration i want them to stack on top of eachoother

Image of what i want

This is my CSS, but after i resize they dont stay even on the bottom. I have the background split with two different colors

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

.column1 {
  height: 100vh;
  background-color: #679289;
}
.column2 {
  height: 100vh;
  background-color: #f4c095;
}

.svg1 {
  overflow: visible;
  transform: translate(0px, 68px);
}

.svg1 {
  
  overflow: visible;
  transform: translate(0px, 166px);
}

Also noting the SVGs are not the same size

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

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

发布评论

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

评论(1

手长情犹 2025-02-04 17:57:50

尝试在DIV中包含元素并使用Flex-Box。您可能必须针对其他布局元素进行调整,但是原理应该相同。

https://codepen.io/jonshipman/pen/pen/pen/pen/pen/zyrokjx

<div class="flex">
  <div>
    <img src="https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/410.svg" />
  </div>

  <div>
    <img src="https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/410.svg" />
  </div>
</div>
.flex {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: transparent;
}

.flex > div {
  flex: 1 0 auto;
}

img {
  width: 5rem;
  height: 5rem;
  display: block;
  margin: 0 auto;
}

div {
  background: blue;
}

div:nth-child(2) {
  background: yellow;
}

@media screen and (max-width:786px) {
  .flex {
    flex-direction:column;
    align-items:center;
  }
  
  .flex > div {
    display:flex;
    align-items:flex-end;
  }
}

Try containing the elements in divs and using flex-box. You might have to adjust it for other layout elements, but the principle should be the same.

https://codepen.io/jonshipman/pen/zYRoKjX

<div class="flex">
  <div>
    <img src="https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/410.svg" />
  </div>

  <div>
    <img src="https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/410.svg" />
  </div>
</div>
.flex {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: transparent;
}

.flex > div {
  flex: 1 0 auto;
}

img {
  width: 5rem;
  height: 5rem;
  display: block;
  margin: 0 auto;
}

div {
  background: blue;
}

div:nth-child(2) {
  background: yellow;
}

@media screen and (max-width:786px) {
  .flex {
    flex-direction:column;
    align-items:center;
  }
  
  .flex > div {
    display:flex;
    align-items:flex-end;
  }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文