css - 如何将 css transition 与 bootstrap flexboxes 一起使用?

标签 css bootstrap-4 flexbox transition

我正在尝试在悬停时向 flexbox 添加一些过渡延迟。但是我的代码似乎有问题。

.flex-fill {  
transition-delay: 250ms !important;
transition:flex 0.5s ease-out !important;
}
.flex-fill:hover {width:60% !important;}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet"/>


<div class="d-flex">
  <div class="p-2 flex-fill bg-light">Flex item</div>
  <div class="p-2 flex-fill bg-success text-white">Flex item with a lot of content</div>
  <div class="p-2 flex-fill bg-dark text-white">Flex item</div>
  <div class="p-2 flex-fill bg-info text-white">Flex item</div>
</div>

最佳答案

您不能使用从自动到 60% 宽度之间的过渡。尝试将原始宽度更改为 100%。并将过渡样式更改为

transition: width 0.5s ease-out !important;

.flex-fill {
  transition-delay: 250ms !important;
  transition: width 0.5s ease-out !important;
  width: 100%;
}

.flex-fill:hover {
  width: 160% !important;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet" />


<div class="d-flex">
  <div class="p-2 flex-fill bg-light">Flex item</div>
  <div class="p-2 flex-fill bg-success text-white">Flex item with a lot of content</div>
  <div class="p-2 flex-fill bg-dark text-white">Flex item</div>
  <div class="p-2 flex-fill bg-info text-white">Flex item</div>
</div>

关于css - 如何将 css transition 与 bootstrap flexboxes 一起使用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56145276/

相关文章:

css - IE9 中的 SVG 背景图像

CSS:倾斜按钮边框,而不是文本

html - 修复 rtl bootstrap 导航栏目录

javascript - 如何在 json 值中使用一些 html 元素标签

jquery - 切换额外的 flexbox div

css - 具有百分比宽度但固定边距的 Flexbox

css - 垂直对齐 3 个背景图像

Python:在 lxml.cssselect 中使用的 CSS 选择器

jquery - Bootstrap : Form implementation using modal within modal

css - 在子元素上移动 flex 元素的滚动