【问题标题】:Background linear-gradient not changing real-time in div element背景线性梯度在 div 元素中不会实时改变
【发布时间】:2019-01-09 21:57:34
【问题描述】:

此问题发生在 Chrome 中,但不是 Safari。希望有解决办法。

滚动<div>,当元素具有线性渐变背景时,元素不会实时更新。它只会在您的鼠标离开 <div> 并返回时更新。

我希望<div> 中的背景在我滚动时会发生变化。背景渐变的高度应该大于 div 的高度,这样当您滚动时,您会看到更多的渐变。

这里是指向问题的 CodePen 的链接。 https://codepen.io/brady-brown/live/XoPKJZ

<div class="tipPageSearchButtons">
<div class="tipPageButtons" id="tipPageButtons">
  <div class="tipButton">
    TEST
  </div>
  <div class="tipButton">
    New button
  </div>
  <div class="tipButton">
    Another
  </div>
  <div class="tipButton">
    Keeps going
  </div>
  <div class="tipButton">
    cheers
  </div>
  <div class="tipButton">
    this is a button
  </div>
  <div class="tipButton">
    tips
  </div>
</div>

.tipPageButtons {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 200px;
  width: 35%;
  overflow-y: scroll;
  box-shadow: 0px 0px 10px 0px gray;
  border-radius: 4px;
  background: -webkit-linear-gradient(top, #712EBD,#00A8C6);
  background: linear-gradient(to bottom, #712EBD,#00A8C6);
  background-attachment: local;
}

.tipButton {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  font-family: 'Roboto', sans-serif;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 2.5px;
  font-weight: 600;
  height: 30px;
  color: #FFF;
  width: auto;
  border: none;
  padding: 6px 10px 6px 10px;
  user-select: none;
}

.tipButton:hover {
  border: 1px solid black;
}

.tipButton:active {
  background: transparent;
}

【问题讨论】:

  • 对我来说似乎没问题(在 chrome 上测试)
  • 清除Chrome浏览器缓存,重试。它对我来说很好用,在 Chrome 中测试过。

标签: html css scroll background linear-gradients


【解决方案1】:

对我来说它工作得很好。因此,我认为您需要从浏览器中清除缓存:转到 Inspect Element > Network > Disable Cashe 您可以轻松完成。 希望对你有帮助

【讨论】:

  • 你没事。它正在工作。但在我的 Windows 计算机上,而不是在我的 Mac 上。没什么大不了的,但很高兴知道它起作用了。
【解决方案2】:

它对我来说很好用,在 Chrome 中测试过。在 chorm 上的私人窗口中重试 (Ctrl+Shift+N)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-02-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-16
    相关资源
    最近更新 更多