【问题标题】:Hover effect not working with flexbox in Chrome悬停效果不适用于 Chrome 中的 flexbox
【发布时间】:2016-06-21 21:14:36
【问题描述】:

当我有一个带有居中项目的 flexbox 时,:hover 伪类在 Chrome 中无法正常工作。悬停只针对居中项目的顶部 3/4 进行注册,而不是底部四分之一。 gif showing the problem

#container {
  margin-top: 50px;
  width: 100%;
  height: 50px;
  background-color: rgba(67, 67, 67, 0.8);
  display: flex;
  align-items: center;
  justify-content: flex;
}

#img-container {
  height: 140px;
  width: 140px;
  border-radius: 140px;
  background-color: blue;
}

#img-container:hover {
  border: 5px solid red;
}

#under {
  height: 50px;
  width: 100%;
}
<div id="container">
  <div id="img-container"></div>
</div>
<div id="under"></div>

【问题讨论】:

  • 在 chrome 47 中显示良好
  • @Scott:奇怪,我在 OS X 上使用 Chrome 49。

标签: html css google-chrome hover flexbox


【解决方案1】:

设法解决它。给#img-container 一个z-index 使:hover 正常工作。

【讨论】:

    【解决方案2】:

    当我有一个带有居中项目的 flexbox 时,:hover 伪类在 Chrome 中成功地正常工作。

    【讨论】:

    • 我想确定不只是我,所以我和几个人一起测试了它,他们都遇到了我报告的相同问题(:悬停在底部 30 上不起作用圆的百分比)。我不知道为什么它对某些人有用。
    猜你喜欢
    • 2011-09-10
    • 2021-10-26
    • 1970-01-01
    • 2013-09-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多