eas*_*wee 9 webkit linear-gradients css3
我在webkit浏览器(Chrome,Opera)中遇到了一个奇怪的问题.
测试用例:http://sample.easwee.net/gradient-bug/(登录Chrome或最新Opera)
我有两个由容器包裹的列.我正在应用CSS渐变来为这两列创建背景.颜色停止设置为66%和列具有相同的66%宽度(使用填充来偏移右列).
它在Firefox中正确呈现 - 列布局和渐变停止点匹配,但在基于webkit的浏览器中,颜色停止与列宽不匹配,尽管我已经使用过66%.
HTML:
<div class="special-container">
<div class="special-container-inner">
<div class="special-container-column-L">
<img src="http://placehold.it/1070x600" />
</div>
<div class="special-container-column-R">
<img src="http://placehold.it/530x345" />
<h3>Test</h3>
<p>It uses a dictionary of over 200 Latin words, combined with a handful of model sentence structures, to generate Lorem Ipsum which looks reasonable.</p>
</div>
<div class="clear"></div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
CSS:
.special-container {}
.special-container-inner {max-width:1600px;margin:0 auto;
background: #ff0000;
background: -moz-linear-gradient(left, #ff0000 0%, #ff0000 66%, #2989d8 66%, #2989d8 66%, #2989d8 100%, #207cca 100%, #7db9e8 100%);
background: -webkit-gradient(linear, left top, right top, color-stop(0%,#ff0000), color-stop(66%,#ff0000), color-stop(66%,#2989d8), color-stop(66%,#2989d8), color-stop(100%,#2989d8), color-stop(100%,#207cca), color-stop(100%,#7db9e8));
background: -webkit-linear-gradient(left, #ff0000 0%,#ff0000 66%,#2989d8 66%,#2989d8 66%,#2989d8 100%,#207cca 100%,#7db9e8 100%);
background: -o-linear-gradient(left, #ff0000 0%,#ff0000 66%,#2989d8 66%,#2989d8 66%,#2989d8 100%,#207cca 100%,#7db9e8 100%);
background: -ms-linear-gradient(left, #ff0000 0%,#ff0000 66%,#2989d8 66%,#2989d8 66%,#2989d8 100%,#207cca 100%,#7db9e8 100%);
background: linear-gradient(to right, #ff0000 0%,#ff0000 66%,#2989d8 66%,#2989d8 66%,#2989d8 100%,#207cca 100%,#7db9e8 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ff0000', endColorstr='#7db9e8',GradientType=1 );
}
.special-container-column-L {width:66%;float:left;text-align:right;}
.special-container-column-L img {display:inline-block;vertical-align:top;max-width:100%;opacity:0.8;}
.special-container-column-R {padding-left:66%;}
.special-container-column-R img {display:inline-block;vertical-align:top;max-width:100%;width:100%;opacity:0.9;}
.clear {clear:both;}
Run Code Online (Sandbox Code Playgroud)
截图:

我使用Colorzilla生成器生成渐变.
针对此类问题是否有任何错误报告或解决方法?
对此问题的修复终于在酝酿之中 - 请参阅https://codereview.chromium.org/1457783005。
这是Chrome 中的一个错误功能。
我已经在http://codepen.io/elliz/pen/fCsay上大规模简化了我的测试用例,但它似乎仍然是 Chrome 中的一个问题 - 而且我发现了一个错误报告(如下)。
<div class="wrapper">
<div>
Try resizing this page, the border between two colours should be smooth in most browsers, but will jump around in Chrome.
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
CSS
.wrapper {
background: linear-gradient(to right, #c93 66%, #2989d8 66%);
}
.wrapper div {
width:66%;
border-right: 1px dotted white;
}
Run Code Online (Sandbox Code Playgroud)
可能不得不重新使用 Faux Columns 或其他老式设计......或者如果您的用户群只使用最新的浏览器,请尝试新的闪亮并使用 flexbox ;)
我发现了一个错误 - http://code.google.com/p/chromium/issues/detail?id=233879和https://code.google.com/p/chromium/issues/detail?id=281489
Skia将颜色离散为 256 个级别,以提高(很多)速度。像这样的硬边
渐变(同一色标处有两种颜色)
肯定会显示出这种限制。我们可以寻找提高
精度的方法,但会产生真正的性能成本,因此我们必须确定
这种特定行为在实践中的重要性。