javascript - 如何通过底部坐标而不是顶部坐标来锚定元素

标签 javascript html css reactjs

我正在使用 React 制作一张扑克牌 table 。现在我有需要围绕 table 定位的播放器组件。

enter image description here

我遇到的问题是,当屏幕属性更改时,播放器框也会更改,这正是我想要的,但是前两个的位置锚定在顶部,这导致播放器从 table 。我宁愿将 anchor 放在底部,这样它们就会留在 table 旁边。

enter image description here

最佳答案

如果你在这里使用绝对定位,你可以这样做:

.player {
    top: 200px; /* whatever value you want the bottom of element to be from top */
    margin-top: -100%; /* bring the element back up so the bottom is where the top value set above is */
}

也就是说,我建议在这里使用 CSS 表格或 flexbox 之类的东西。

关于javascript - 如何通过底部坐标而不是顶部坐标来锚定元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46009062/

相关文章:

javascript - 使用 LinqJS 进行分组

html - 无法将导航栏中的 Logo 与按钮对齐

html - CSS 仅可滚动表体

c# - 使用变量从 MVC 中的模型添加纬度、经度 Google Maps API

javascript - ruby 将数组传递给 google javascript

html - 纯 CSS 下拉导航下拉到左侧

html - CSS 背景颜色适用于 DW 但不适用于浏览器

html - 使用 HTML 和 CSS 在 div block 中显示/隐藏元素

JavaScript,数组A长度为0但A[key]有值

javascript - 如何将innerHTML添加到现有属性