Banishing the Background Stripes from Linear Gradient
When employing the linear-gradient property for a background, you may encounter noticeable stripes when the direction is set to top or bottom. These unsightly artifacts can be attributed to a complex background propagation phenomenon.
In case of a vertically-oriented gradient, the margin of the body element propagates to the HTML element, resulting in an 8px tall area. Subsequently, the linear-gradient extends across this entire height, producing repeating patterns.
Solution:
To address this issue, ensure that the body element has a sufficient height. By specifying a height of any value greater than 0 (e.g., 100vh), you can prevent the background from collapsing and eliminate the distracting stripes. This resolves the propagation issues, allowing the linear gradient to be applied smoothly without disruptions.
<div><div class="snippet-code">
<pre> height: 100vh;
background: linear-gradient(to top, red, yellow);
}</pre>
</p>
免責聲明: 提供的所有資源部分來自互聯網,如果有侵犯您的版權或其他權益,請說明詳細緣由並提供版權或權益證明然後發到郵箱:[email protected] 我們會在第一時間內為您處理。
Copyright© 2022 湘ICP备2022001581号-3