html - 在 Bootstrap col 中定位绝对项

标签 html css twitter-bootstrap

我正在尝试将绝对定位的 block 动画化到 Bootstrap 列中。

问题是 bootstrap col 没有固定宽度,所以在不同的屏幕上,我所有的绝对元素都会有不同的

What would be amazing is that if I set an element to for example: translateX(50%). It will always be in the center of my col-xs-4

enter image description here

有没有人有这方面的经验?

我试过了

使用 transform:translate 百分比或像素。

@keyframes animation {
    0% {transform: translateX(-100%) }
    100% {transform: translateX(0) }
}

这不起作用,因为百分比不是基于 Bootstrap 列的宽度。所以它不是响应式的,并且对于每个屏幕尺寸,最终都会出现在不同的地方。

最佳答案

左:50%; transform: translateX(-50%;) 将在 .col-xs-4

中水平居中

关于html - 在 Bootstrap col 中定位绝对项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41962523/

相关文章:

html - 在 Heroku 上提供从 NodeJS 以编程方式生成的 HTML 文件

php - wordpress 下拉菜单的样式不正确,因为它们继承了父项的样式。想要为下拉菜单提供自定义背景

html - 仅在 Firefox 中有额外间距但未在检查器中显示

html - 将 <!DOCTYPE> 更改为 <!DOCTYPE html> 会导致我的包装器无法扩展

javascript - 如何在一定距离内停止 twitter bootstrap scrollspy?

html - Bootstrap 导航栏不是很灵敏

html - CSS 下拉菜单 - 超时

html - 如何制作悬停菜单栏?

jquery - Bootstrap 3 登录表单和 jQuery 验证插件

javascript - 将鼠标悬停在输入的背景颜色上并删除禁用的红色圆圈?