Background linear-gradient not changing real-time in div element

时间:2019-01-09 21:57:34

标签: html css scroll background linear-gradients

This problem occurs in Chrome but not Safari. Hoping there is a solution.

Scrolling through a <div>, when the element has a linear-gradient background, the element doesn't update in real-time. It only updates once your mouse leaves the <div> and comes back.

I would expect the background in the <div> to change when I scroll. The height of the background gradient should extend greater than the height of the div so that way when you scroll, you're seeing more of the gradient.

Here is a link to the CodePen with the issue. 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;
}

2 个答案:

答案 0 :(得分:0)

对我来说很好。因此,我认为您需要从浏览器中清除缓存:转到检查元素>网络>禁用Cashe 您可以轻松地做到这一点。 希望有帮助

答案 1 :(得分:0)

在Chrome上进行了测试,对我来说效果很好。在私人视窗(chrom(Ctrl + Shift + N))中重新尝试