css - 如何在引导弹性盒中使用 css 过渡?
问题描述
我正在尝试在悬停时向 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>
推荐阅读
- javascript - 允许在 chrome 扩展内容脚本中使用 jQuery
- mongodb - 在 mongodb 中使用 $in 更新集合中的许多字段
- javascript - 跟随鼠标指针的粘球
- ms-access - 访问附件字段添加,表单中禁用更新按钮
- javascript - JavaScript - 自定义 Google 登录必须点击两次
- c++ - { } 和等号变量之间的区别
- regex - 将所有正则表达式匹配捕获到一个向量中
- c# - LINQ - 使用 SUM IF 分组
- javascript - 使用 ajax 发送带有嵌套在列表中的文件的 json
- python - 有没有更好的方法在线程中运行 uvicorn?